public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* sigwait() breaks when straced
@ 2005-07-30 23:50 Sanjoy Mahajan
  2005-07-31 17:59 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Sanjoy Mahajan @ 2005-07-30 23:50 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-kernel

Pavel Machek wrote:
> If you think it is a linux bug, can you produce small test case doing
> just the sigwait, and post it on l-k with big title "sigwait() breaks
> when straced, and on suspend"?

Here it is.  I haven't tested the sigwait()+suspend lately, since
suspend isn't working with any kernel except 2.6.11.4 and I'm chasing
down other acpi errors in 2.6.13-*.  But here's a test case for how
sigwait() breaks when straced (see C file below).  It is with 2.6.13-rc4
on a Thinkpad 600X (Pentium III), Debian 'testing', libc
2.3.2.

  $ gcc waiting.c -o waiting -lpthread
  $ ./waiting
  Sigwaiting...[strace my pid, which is 3359]
  [in another shell I run 'strace -p 3359', and get:]
  sigwait() returned 4, errno=0, sig=77

In the strace window, I get 

  $ strace -p 3359
  Process 3359 attached - interrupt to quit
  write(2, "sigwait() returned 4, errno=0, s"..., 39) = 39
  exit_group(4)                           = ?
  Process 3359 detached

According to the man entry for sigwait:

       The !sigwait! function never returns an error.

so the return value should not be 4 (or the docs are not right).

Here's waiting.c:

#include <stdio.h>
#include <pthread.h>
#include <signal.h>
#include <errno.h>

sigset_t mask;

int main () {
  int ret, id;
  int sig = 77;			/* easy to see if it gets changed */

  id = getpid();
  sigemptyset(&mask);
  fprintf (stderr, "Sigwaiting...[strace my pid, which is %d]\n", id);
  ret = sigwait(&mask, &sig);
  fprintf (stderr,
	   "sigwait() returned %d, errno=%d, sig=%d\n",
	   ret, errno, sig);
  return ret;
}


-Sanjoy

`A society of sheep must in time beget a government of wolves.'
   - Bertrand de Jouvenal

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

* Re: sigwait() breaks when straced
  2005-07-30 23:50 sigwait() breaks when straced Sanjoy Mahajan
@ 2005-07-31 17:59 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-07-31 17:59 UTC (permalink / raw)
  To: Sanjoy Mahajan; +Cc: Pavel Machek, linux-kernel

On 7/30/05, Sanjoy Mahajan <sanjoy@mrao.cam.ac.uk> wrote:
> so the return value should not be 4 (or the docs are not right).

This return value simply indicated EINTR (sigwait does not set errno,
read the docs).

The kernel simply doesn't restart the function in case of a signal. 
It should do this, though.

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

end of thread, other threads:[~2005-07-31 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-30 23:50 sigwait() breaks when straced Sanjoy Mahajan
2005-07-31 17:59 ` Ulrich Drepper

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