chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] remove enable/disable interrupt flag


From: Alan Post
Subject: Re: [Chicken-users] remove enable/disable interrupt flag
Date: Fri, 30 Sep 2011 10:55:47 -0601

> > Your other points about multiple signals sugget it should be a proper
> > queue, not just a bitmask. Although I have a vague feeling that Unix was
> > allowed to coalesce pending signals as it just used a bitmask itself...
> 
> In the old days, yes.  Now signals have guaranteed delivery, at least if
> you use sigaction() to catch them.  I suspect that most of our systems
> in fact will work with signal(), as it's just a thin layer over sigaction(),
> but better not to rely on that.
> 

I wrote a test program (below) to test signal delivery from C.  I
was surprised to find signals being coalesced on OpenBSD, my test
system.  This program for me receives far fewer than 256 signals.

I think your point about signal being a wrapper around sigaction
deserves to be repeated: it's my understanding too, and means that
as it stands, my sigaction patch is essentially or completely a
no-op on most platforms.  Jerry's experience with it confusingly
not-withstanding.

-Alan

<++> gcc -o child child.c && ./child
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <errno.h>

volatile sig_atomic_t child_count=0;

void
chld(int signum)
{
  ++child_count;
}

main()
{
  struct sigaction sa;
  int i, status;
        pid_t pid;

        sa.sa_handler=chld;
        sa.sa_flags = 0;
        sigemptyset(&sa.sa_mask);
        sigaddset(&sa.sa_mask, SIGCHLD);

        sigaction(SIGCHLD, &sa, 0);

  for(i=0; i<256; ++i) {
          switch(pid=fork()) {
                case -1:
                        fprintf(stderr, "fork: %s\n", strerror(errno));
                        continue;
          case 0:
                  _exit(0);
          default:
                  break;
                }
        }

        for(i=0; i<256; ++i) {
restart_wait:
                if(-1==waitpid(WAIT_ANY, &status, 0)) {
                        if(EINTR==errno) goto restart_wait;
                        fprintf(stderr, "wait: %s\n", strerror(errno));
                        break;
                }
        }

        printf("%d\n", child_count);
        exit(0);
}
<-->
-- 
.i ma'a lo bradi cu penmi gi'e du



reply via email to

[Prev in Thread] Current Thread [Next in Thread]