sigwait() breaks when straced

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

 



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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux