Changeset 510
- Timestamp:
- 07/12/11 13:06:33 (10 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
man/crtmpserver.1 (modified) (1 diff)
-
sources/crtmpserver/src/crtmpserver.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/man/crtmpserver.1
r374 r510 57 57 .B \-\-gid=<gid> 58 58 Run the process with the specified group id. 59 .TP 60 .B \-\-pid=<file name> 61 This option tells \fBcrtmpserver\fP to use the specified file as its pidfile. If the file exists, it will be over-written. 62 .br 63 Works only if \fB--daemon\fP option is specified. 59 64 .SH FILES 60 65 .TP -
trunk/sources/crtmpserver/src/crtmpserver.cpp
r474 r510 61 61 void NormalizeCommandLine(string configFile); 62 62 bool ApplyUIDGID(); 63 void WritePidFile(pid_t pid); 63 64 64 65 RunningStatus gRs; … … 170 171 171 172 if (pid > 0) { 173 if (gRs.commandLine["arguments"].HasKey("--pid")) 174 WritePidFile(pid); 172 175 return false; 173 176 } … … 292 295 cout << " --gid=<gid>" << endl; 293 296 cout << " Run the process with the specified group id\n" << endl; 297 cout << " --pid=<pid_file>" << endl; 298 cout << " Create PID file."<< endl; 299 cout << " Works only if --daemon option is specified\n"<< endl; 294 300 } 295 301 … … 342 348 } 343 349 350 void WritePidFile(pid_t pid) { 351 /*! 352 * Check if PID file exists 353 * If exists -> skip pid file creation 354 * if none -> write pid file 355 */ 356 string pidFile = gRs.commandLine["arguments"]["--pid"]; 357 struct stat sb; 358 if (stat(pidFile.c_str(), &sb) == 0) { 359 printf("pid file exists\n"); 360 } else if (errno != ENOENT) { 361 perror("stat"); 362 return; 363 } 364 365 FILE * f; 366 f = fopen(pidFile.c_str(), "w"); 367 if (f == NULL) { 368 perror("fopen"); 369 printf("warn: can not create PID file %s\n", pidFile.c_str()); 370 return; 371 } 372 fprintf(f, "%d", pid); 373 if (fclose(f) == -1) { 374 perror("fclose"); 375 } 376 } 377 344 378 #ifdef COMPILE_STATIC 345 379 #ifdef HAS_APP_ADMIN
Note: See TracChangeset
for help on using the changeset viewer.
