All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <hancockr@shaw.ca>
To: Li Xiaodong <lixd@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [HELP]Problem with exit(0) and _exit(0) on RHEL x86
Date: Mon, 21 Jan 2008 17:54:39 -0600	[thread overview]
Message-ID: <479530BF.10606@shaw.ca> (raw)
In-Reply-To: <fa.YRcO5m0fsaAu8VNfQMYpdgaX5qk@ifi.uio.no>

Li Xiaodong wrote:
> I thought the effects of exit(0) and _exit(0) should be different.
> 
> ----
> int main(void)
> {
>         int var = 0;
>         pid_t pid;
> 
>         printf("before vfork\n");
>         if ( (pid = vfork()) < 0 )
>                 printf("error\n");
>         else if ( pid == 0 )
>         {
>                 var++;
>                 exit(0);  /* Clear parent's IO */
>         }
> 
>         printf("%d\n",var);
>         return 0;
> }
> 
> ----
> 
> int main(void)
> {
>         int var = 0;
>         pid_t pid;
> 
>         printf("before vfork\n");
>         if ( (pid = vfork()) < 0 )
>                 printf("error\n");
>         else if ( pid == 0 )
>         {
>                 var++;
>                 _exit(0);  /* Do not clear parent's IO */
>         }
> 
>         printf("%d\n",var);
>         return 0;
> }
> 
> ----
> 
> But the actual results on RHEL5 x86 were beyond my ken. The outputs of the
> above two are the same. 
> 
> $./a.out
> before vfork
> 1
> 
> Could anyone help me with this? Thanks.

Why do you expect a different result? Also, calling exit from a vforked 
child is explicitly not allowed. The only things you can do are execve 
or _exit.

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/


       reply	other threads:[~2008-01-21 23:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.YRcO5m0fsaAu8VNfQMYpdgaX5qk@ifi.uio.no>
2008-01-21 23:54 ` Robert Hancock [this message]
2008-01-21  8:40 [HELP]Problem with exit(0) and _exit(0) on RHEL x86 Li Xiaodong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=479530BF.10606@shaw.ca \
    --to=hancockr@shaw.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixd@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.