tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

WSTOPPED in <sys/wait.h>



Currently, (if XOPEN_SOURCE or NETBSD_SOURCE) <sys/wait.h>
defines the symbol WSTOPPED as ...

./sys/sys/wait.h:#define        WSTOPPED        _WSTOPPED

(this is from a grep -R on a set of current sources just updated
within the past hour or two - the root of the grep is what would normally
be /usr/src .. xsrc is under there as well, but not 
pkgsrc.)

Now in that _WSTOPPED and its usage is clear:

./sys/sys/wait.h:#define        _WSTOPPED       0177            /* _WSTATUS if process is stopped */
./sys/sys/wait.h:#define WIFSTOPPED(x)  (_WSTATUS(x) == _WSTOPPED)
./sys/sys/wait.h:#define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
./sys/sys/wait.h:#define        W_STOPCODE(sig)         ((sig) << 8 | _WSTOPPED)

_WSTOPPED is the status value that indicates that a process has
stopped, rather than exited.


Aside from the definition above, the sole use I can find of WSTOPPED
(without the underscore) in the NetBSD source tree is this one ...
(grep result split into two lines for this e-mail)

./external/bsd/libproc/dist/proc_bkpt.c:
        } else if (waitpid((proc_getpid(phdl), &status, WSTOPPED) == -1) {

which is using WSTOPPED as if it were a flag, akin to WNOHANG, WNOWAIT (etc).

That waitpid() call in proc_bkpt.c (about which I did not check to see if
it is actually used for anything on NetBSD - that one line is all I have seen
of the file) is effectively doing

	waitpid(xxx, &status, WNOHANG|WUNTRACED|WALTSIG|WALLSIG|0160);

which I doubt is what it intends.

This confusion may be caused by the use of WSTOPPED as a flag to the
(unimplemented on NetBSD) posix waitid() function (or on FreeBSD, wait6()
which looks like a superset of waitid())

Should the WSTOPPED perhaps be entirely removed from <sys/wait.h>, or
possibly replaced by something which (perhaps in the future) could
actually be a flag value (even 0 would be better than its current value).

It is hard to believe there is any non-NetBSD code using WSTOPPED which
expects the NetBSD semantics, and from what I can see, aside from that single
reference, there's nothing in NetBSD that even cares if it exists or not.

kre



Home | Main Index | Thread Index | Old Index