public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* waitid() return value strangeness when infop is NULL
@ 2009-01-13 22:36 Michael Kerrisk
       [not found] ` <cfd18e0f0901131436ud2cf61bkf0e6b00f4b765bb5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Kerrisk @ 2009-01-13 22:36 UTC (permalink / raw)
  To: Roland McGrath
  Cc: Ulrich Drepper, Vegard Nossum,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	lkml-u79uwXL29TY76Z2rM5mHXA

Hello Roland,

Vegard sent me a report of a possible bug in the waitid(2) man page,
but on closer examination, the issue seems to be in the waitid()
system call.

POSIX.1 says of waitid():

   RETURN VALUE
       If WNOHANG was specified and there are no children to wait for,
       0 shall be returned. If waitid() returns due to the  change  of
       state  of  one of its children, 0 shall be returned. Otherwise,
       -1 shall be returned and errno set to indicate the error.

The Linux waitid() follows this behavior, as long as infop is not
NULL, which is what POSIX requires:

       The  application shall ensure that the infop argument points to
       a siginfo_t structure.

However, Linux's waitid() does permit infop to be NULL.  But in this
case, a successful call returns the PID of the waited-for child.
Thinking about it, I suppose there is a rationale for doing this,
since otherwise the caller of waitid() has no way of obtaining the PID
of the waited-for child.  Anyway, this behavior should either be
documented, or "fixed" (i.e., change waitid() to return 0 on success
even if infop is NULL).  So, some questions:

a) Is it intentional to support the infop==NULL case for waitid() --
rather than simply giving an error return?

b) If so, what is the rationale for supporting this feature?

c) If the the answer a) is "yes", is it intentional for
waitid(idtype,id,NULL,options) to return the PID of the child, rather
than returning 0?

I'll post a test program in a follow-up message.

Cheers,

Michael
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2009-01-14  2:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-13 22:36 waitid() return value strangeness when infop is NULL Michael Kerrisk
     [not found] ` <cfd18e0f0901131436ud2cf61bkf0e6b00f4b765bb5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-13 22:38   ` Michael Kerrisk
     [not found]     ` <cfd18e0f0901131438n232ba114n27ea2d7964d071de-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-13 22:43       ` Michael Kerrisk
2009-01-13 22:47       ` Roland McGrath
     [not found]         ` <20090113224759.7DFB7FC3DD-nL1rrgvulkc2UH6IwYuUx0EOCMrvLtNR@public.gmane.org>
2009-01-13 22:49           ` [PATCH] sys_waitid: return -EFAULT for NULL Roland McGrath
     [not found]             ` <20090113224941.36F19FC3DD-nL1rrgvulkc2UH6IwYuUx0EOCMrvLtNR@public.gmane.org>
2009-01-13 23:14               ` Michael Kerrisk
     [not found]                 ` <cfd18e0f0901131514i2f7be7f1t2c6275c26dbb6874-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-13 23:24                   ` Andrew Morton
     [not found]                     ` <20090113152457.0d7685ad.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-01-13 23:36                       ` Michael Kerrisk
2009-01-13 23:47                       ` Roland McGrath
     [not found]                         ` <20090113234716.765A8FC3DD-nL1rrgvulkc2UH6IwYuUx0EOCMrvLtNR@public.gmane.org>
2009-01-14  0:13                           ` Michael Kerrisk
     [not found]                             ` <cfd18e0f0901131613l65bff51fo22e86a01ba2c0720-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-14  0:24                               ` Ulrich Drepper
2009-01-14  0:33               ` Linus Torvalds
     [not found]                 ` <alpine.LFD.2.00.0901131629220.6528-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-01-14  0:53                   ` Michael Kerrisk
     [not found]                     ` <cfd18e0f0901131653y76a827b5i906fadce63ada56b-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-14  0:57                       ` Linus Torvalds
     [not found]                         ` <alpine.LFD.2.00.0901131655040.6528-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-01-14  1:39                           ` Michael Kerrisk
     [not found]                             ` <cfd18e0f0901131739v5119271flc28b5531604e682-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-14  2:10                               ` Linus Torvalds
     [not found]                                 ` <alpine.LFD.2.00.0901131808070.6528-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-01-14  2:28                                   ` Michael Kerrisk
2009-01-13 22:47   ` waitid() return value strangeness when infop is NULL Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox