Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
That last commit screws the fork tree structure. Just don't printf
Browse files Browse the repository at this point in the history
  • Loading branch information
lutoma committed Jun 9, 2012
1 parent fbcb469 commit 527269d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ int main(int argc, char* argv[], char* envp[])
MagickWandGenesis();
atexit(MagickWandTerminus);

/* Fork a new master process to daemonize and exit the old one. We use
* _Exit here to not trigger the atexit that terminates ImageMagick.
*/
if(fork())
_Exit(EXIT_SUCCESS);

// Fork worker processes
syslog(LOG_INFO, "Forking workers\n");

worker_pids = calloc(num_workers, sizeof(pid_t));
if(!worker_pids)
error_errno("worker_pids: Could not allocate", 1);
Expand All @@ -151,14 +157,6 @@ int main(int argc, char* argv[], char* envp[])
// The following code is only executed in the master process.
if(worker_id > num_workers)
{
printf("Successfull startup, see syslog for details\n");

/* Fork a new master process to daemonize and exit the old one. We use
* _Exit here to not trigger the atexit that terminates ImageMagick.
*/
if(fork())
_Exit(EXIT_SUCCESS);

syslog(LOG_INFO, "master (PID %d): Sleeping until I receive a signal.\n", getpid());

/* Sleep a little until we get a SIG{TERM,HUP,INT} or one of our
Expand Down

0 comments on commit 527269d

Please sign in to comment.