develooper Front page | perl.perl5.porters | Postings from October 2001

Re: MacOS X.1 build w/some problems

Thread Previous
From:
=?ISO-8859-1?Q?Kay_R=F6pke?=
Date:
October 26, 2001 05:27
Subject:
Re: MacOS X.1 build w/some problems
Message ID:
DB1382D8-CA0C-11D5-86A5-000393414688@dolphin-services.de

On Freitag, Oktober 26, 2001, at 10:28  AM, schwern@pobox.com wrote:

> I just installed MacOS X 10.1, and boy is it perdy.  I've got rootless
> X working, Xemacs, gimp...

Well, UNIX does have some advantages ;-)

> ../ext/POSIX/t/posix..................ok 11/29Test output counter 
> mismatch [test 11]
> ../ext/POSIX/t/posix..................FAILED test 10
>         Failed 1/29 tests, 96.55% okay
>
> Test #10 never shows up.  That's SIGINT.  A little test program works:
>
> 	perl -wle '$SIG{INT} = sub { print "Foo!\n" };  kill "INT", $$'
> 	Foo!
>
> So something must be wrong with POSIX::SigSet.

I have this problem since I have OS X now.
See also http://www.xray.mpe.mpg.de/mailing-
lists/perl5-porters/2001-10/msg00536.html

IMHO the problem is not the SIGINT, but rather the procmask set in the 
test (which I messed up in the above message).
Actually what the test is about is a nested handling of signals.
The SIGHUP handler has a mask with a blocked SIGINT and itself sends a 
SIGINT to the its own process.
To succeed the tests, the SIGINT handler is supposed to be called, which 
it isn't on Mac OS X 10.[0|1]. This does work for me on different Linux 
versions as expected.

Closer examination shows that the SIGINT is (after being dispatched) 
shows up as pending for the process. I would expect the SIGHUP handler 
to be executed and then the SIGINT handler to be called, because of the 
pending signal, but the pending signal is ignored. I unfortunately have 
no idea if this conforms to POSIX or not, but someone isn't obeying 
POSIX here. It's either Linux or Darwin. I can't really decide which one 
should be executed.

Help appreciated.

Regards,

Kay

P.S.: test program follows. Send it a SIGHUP to start test. Works fine 
on Linux 2.4.4 (SuSE) crashes with bus error on Darwin 1.4.1.

#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

void sigINT (int sig) {
   printf ("SigINT received\n");
}

void sigHUP (int sig) {
   pid_t pid = getpid ();
   sigset_t *sigset;

   printf ("SigHUP received\n");
   printf ("Killing process no %d\n", pid);
   kill (pid, SIGINT);
   sigpending (sigset);
   if (sigismember (sigset, SIGINT)) {
     printf ("SIGINT is pending\n");
   }
}

void main () {
   struct sigaction sa,sa1;

   sa.sa_flags = 0;
   sa.sa_handler = sigINT;
   sigemptyset (&sa.sa_mask);
   sigaddset (&sa.sa_mask, SIGINT);
   sigaction (SIGINT, &sa, NULL);

   sa1.sa_flags = 0;
   sa1.sa_handler = sigHUP;
   sigemptyset (&sa1.sa_mask);
   sigaddset (&sa1.sa_mask, SIGINT);
   sigaction (SIGHUP, &sa1, NULL);
   while (1) {
   }
}


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About