Re: [OT] 'volatile' in userspace

Joshua Hudson
2006-07-10T17:00:39Z

>
> 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 */
}