| 5557 | #endif /* __linux__ */ |
| 5558 | |
| 5559 | void createPidFile(void) { |
| 5560 | /* If pidfile requested, but no pidfile defined, use |
| 5561 | * default pidfile path */ |
| 5562 | if (!server.pidfile) server.pidfile = zstrdup(CONFIG_DEFAULT_PID_FILE); |
| 5563 | |
| 5564 | /* Try to write the pid file in a best-effort way. */ |
| 5565 | FILE *fp = fopen(server.pidfile,"w"); |
| 5566 | if (fp) { |
| 5567 | fprintf(fp,"%d\n",(int)getpid()); |
| 5568 | fclose(fp); |
| 5569 | } |
| 5570 | } |
| 5571 | |
| 5572 | void daemonize(void) { |
| 5573 | int fd; |