lkml.org 
[lkml]   [2006]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [OT] 'volatile' in userspace
Joshua Hudson wrote:
>>
>> So this would tend to confirm the rule of thumb: use of "volatile" in
>> a userspace progam tends to indicate a bug.
>>
>> - Ted
>
>
> No. vfork(), setjmp(), signal().
>
> Yes, I use vfork. So far, the only way I have found for the parent to
> know whether or not the child's exec() failed is this way:
>
> volatile int failed;
> pid_t pid;
>
> failed = 0;
> if (0 == (pid = vfork())) {
> execve(argv[0], argv, envp);
> failed = errno;
> _exit(0);
> }
> if (pid < 0) {
> /* can't fork */
> }
> if (failed) {
> /* wait for pid (clean up zombie) */
> errno = failed;
> /* can't exec: update state */
> }

May not be portable because you're apparently not supposed to assume
anything about the memory sharing semantics (eg. it may share memory
or it may not -- AFAIK if your code doesn't work correctly after
replacing vfork with fork, then it is buggy).

What's wrong with _exit(exec() == -1 ? 0 : errno);
and picking up the status with wait(2) ?

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-11 00:25    [W:0.374 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site