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

[MiNT] waitpid-return-value if WNOHANG



Hi,

Posix says for waitpid():

...
If waitpid() was invoked with WNOHANG set in options, it has at least one
child process specified by pid for which status is not available, and
status is not available for any process specified by pid, 0 is returned.
Otherwise, -1 shall be returned, and errno set to indicate the error.
...
The waitpid() function shall fail if:
[ECHILD]
The process specified by pid does not exist or is not a child of the calling process, or the process group specified by pid does not exist or does not have any member process that is a child of the calling process.
[EINTR]
The function was interrupted by a signal. The value of the location pointed to by stat_loc is undefined.
[EINVAL]
The options argument is not valid.


k_exit.c#465 says:

        {
          /* Don't report that for WNOHANG.  */
          if (!(nohang & 1))
            DEBUG(("Pwaitpid: no children found"));

          return ENOENT;
        }

and mintlib/unix/wait4.c:

    if (retval < 0) {
      if (retval == -ENOENT || retval == -ECHILD)
        {
          if (options & WNOHANG)
            return 0;          /* Work-around for kernel bug.  */
          retval = -ECHILD;
        }

I think pwaitpid in MiNT should return ECHILD, and wait4 in the mintlib
should return -1. Or would that break existing programs?

-Helmut
--