* [HELP]Problem with exit(0) and _exit(0) on RHEL x86
@ 2008-01-21 8:40 Li Xiaodong
0 siblings, 0 replies; 2+ messages in thread
From: Li Xiaodong @ 2008-01-21 8:40 UTC (permalink / raw)
To: linux-kernel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [HELP]Problem with exit(0) and _exit(0) on RHEL x86
[not found] <fa.YRcO5m0fsaAu8VNfQMYpdgaX5qk@ifi.uio.no>
@ 2008-01-21 23:54 ` Robert Hancock
0 siblings, 0 replies; 2+ messages in thread
From: Robert Hancock @ 2008-01-21 23:54 UTC (permalink / raw)
To: Li Xiaodong; +Cc: linux-kernel
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-21 23:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <fa.YRcO5m0fsaAu8VNfQMYpdgaX5qk@ifi.uio.no>
2008-01-21 23:54 ` [HELP]Problem with exit(0) and _exit(0) on RHEL x86 Robert Hancock
2008-01-21 8:40 Li Xiaodong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox