| delorie.com/archives/browse.cgi | search | 
| Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm | 
| Sender: | cygwin-owner AT sourceware DOT cygnus DOT com | 
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com> | 
| List-Archive: | <http://sourceware.cygnus.com/ml/cygwin/> | 
| List-Help: | <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, | 
| <http://sourceware.cygnus.com/ml/#faqs> | |
| Delivered-To: | mailing list cygwin AT sourceware DOT cygnus DOT com | 
| To: | cygwin AT sourceware DOT cygnus DOT com | 
| Subject: | Re: fork() problem | 
| References: | <19990801003028 DOT 61496 DOT qmail AT hotmail DOT com> | 
| Mime-Version: | 1.0 (generated by tm-edit 7.108) | 
| From: | Ian T Zimmerman <itz AT lbin DOT com> | 
| Date: | 02 Aug 1999 16:38:24 +0000 | 
| In-Reply-To: | "unknown user"'s message of "Sat, 31 Jul 1999 20:30:27 EDT" | 
| Message-ID: | <87rkknlaan.fsf@amazon.lbin.com> | 
| Lines: | 30 | 
| X-Mailer: | Gnus v5.6.45/XEmacs 21.0(beta67) - "20 minutes to Nikko" | 
    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 AT sourceware DOT cygnus DOT com
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |