This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: fork() problem



    unknown> Here's the problem... If I compile the program with this
    unknown> code.. it just crashes, but if i comment this out it
    unknown> compiles and runs fine even though it's not running as
    unknown> it's suppose to be...

/* some code here*/

switch (fork()) {
    case -1:
      printf("Couldn't run in background, exiting...\n");
      exit(1);
      break;
    case 0:
      break;
    default:
      printf("Running in background...\n");
      exit(0);
      break;
  }
/* other stuff*/

This is probably not the cause of your problem, but even on true POSIX 
systems you're not supposed to use exit() in the default case.  Use
_exit() instead.

-- 
Ian Zimmerman
Lightbinders, Inc.
2325 3rd Street #324, San Francisco, California 94107


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]