ratpoison-devel
[Top][All Lists]
Advanced

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

[RP] Solaris/CDE problem solved


From: Brian Lo Bue
Subject: [RP] Solaris/CDE problem solved
Date: Fri, 5 Jan 2001 15:51:52 -0800 (PST)

Hi All,

If you've been looking at the list the past few days you've seen my
attempt to get ratpoison to play nice with Solaris/CDE.  I've figured
out what is going on.  

Way back in the mist of time when a process called signal() the
handler was only set for one invocation.  So you'd have to put another 
signal() call in your handler so that the next signal would be
handled.  As it turns out SVR4 systems, like Solaris, use the default
old behavior for signal and BSD type systems reinstall the handler
automatically.  I'm gonna infer from this that Linux reinstalls the
handler since I'm pretty sure that this works on other people's
machines.  Long story short, I changed the calls to a POSIX version
rebuilt and now it behaves as expected.  The diffs follow:

30d29
< #include <errno.h>
144,229d142
< void
< set_sig_handlers (void)
< {
<   /*
<    * use sigaction because SVR4 systems do not replace the signal handler
<    * by default which is a tip of the hat to some god-aweful ancient
<    * code.  So use the POSIX sigaction call instead.
<    */
<   struct sigaction act;
<       
<   /* check setting for SIGALRM */
<   if (sigaction (SIGALRM, NULL, &act)) {
<       /* error condition */
<       fprintf( stderr, "\n\nerror %d fetching SIGALRM handler\n", errno );
<   } else {
<       /* if the existing action is to ignore then leave it
<        * intact otherwise add our handler
<        */
<       if (act.sa_handler != SIG_IGN) {
<           act.sa_handler = alrm_handler;
<           sigemptyset(&act.sa_mask);
<           act.sa_flags = 0;
<           if (sigaction (SIGALRM, &act, NULL)) {
<               fprintf( stderr, "\n\nerror %d setting SIGALRM handler\n", 
errno );
<           }
<       }
<       
<   }
<   /* check setting for SIGTERM */
<   if (sigaction (SIGTERM, NULL, &act)) {
<       /* error condition */
<       fprintf( stderr, "\n\nerror %d fetching SIGTERM handler\n", errno );
<   } else {
<       /* if the existing action is to ignore then leave it
<        * intact otherwise add our handler
<        */
<       if (act.sa_handler != SIG_IGN) {
<           act.sa_handler = sighandler;
<           sigemptyset(&act.sa_mask);
<           act.sa_flags = 0;
<           if (sigaction (SIGTERM, &act, NULL)) {
<               fprintf( stderr, "\n\nerror %d setting SIGTERM handler\n", 
errno );
<           }
<       }
<       
<   }
<   /* check setting for SIGINT */
<   if (sigaction (SIGINT, NULL, &act)) {
<       /* error condition */
<       fprintf( stderr, "\n\nerror %d fetching SIGINT handler\n", errno );
<   } else {
<       /* if the existing action is to ignore then leave it
<        * intact otherwise add our handler
<        */
<       if (act.sa_handler != SIG_IGN) {
<           act.sa_handler = sighandler;
<           sigemptyset(&act.sa_mask);
<           act.sa_flags = 0;
<           if (sigaction (SIGINT, &act, NULL)) {
<               fprintf( stderr, "\n\nerror %d setting SIGINT handler\n", errno 
);
<           }
<       }
<       
<   }
<   /* check setting for SIGHUP */
<   if (sigaction (SIGHUP, NULL, &act)) {
<       /* error condition */
<       fprintf( stderr, "\n\nerror %d fetching SIGHUP handler\n", errno );
<   } else {
<       /* if the existing action is to ignore then leave it
<        * intact otherwise add our handler
<        */
<       if (act.sa_handler != SIG_IGN) {
<           act.sa_handler = hup_handler;
<           sigemptyset(&act.sa_mask);
<           act.sa_flags = 0;
<           if (sigaction (SIGHUP, &act, NULL)) {
<               fprintf( stderr, "\n\nerror %d setting SIGHUP handler\n", errno 
);
<           }
<       }
<       
<   }
<   
< }
< 
< 
317c230,233
<   set_sig_handlers();
---
>   if (signal (SIGALRM, alrm_handler) == SIG_IGN) signal (SIGALRM, SIG_IGN);
>   if (signal (SIGTERM, sighandler) == SIG_IGN) signal (SIGTERM, SIG_IGN);
>   if (signal (SIGINT, sighandler) == SIG_IGN) signal (SIGINT, SIG_IGN);
>   if (signal (SIGHUP, hup_handler) == SIG_IGN) signal (SIGHUP, SIG_IGN);

Feel free to include it in the tree if you'd like.

Brian



reply via email to

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