what should SIGINT default to?

what should SIGINT default to?

Post by Marty Leisner 257 » Thu, 06 Jul 1995 04:00:00



The glibc manual says:
Macro: int SIGTERM

The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL,
this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to
terminate.

The shell command kill generates SIGTERM by default.

SIGTERM doesn't invoke exit, so any atexit()
isn't processed...is this correct?

I had to do
signal(SIGINT, exit)
to generate the behavior I wanted...

In the posix specs, I didn't see an explanation of what SIG_DFL is supposed
to do...

--
marty

Member of the League for Programming Freedom (see http://www.lpf.org/)
"I just know I'm a better manager when I have Joe DiMaggio in center field"
                        Casey Stengel

 
 
 

what should SIGINT default to?

Post by Doug Royer [KD6HB » Thu, 06 Jul 1995 04:00:00



Quote:

> The glibc manual says:
> Macro: int SIGTERM

> The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL,
> this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to
> terminate.

> The shell command kill generates SIGTERM by default.

> SIGTERM doesn't invoke exit, so any atexit()
> isn't processed...is this correct?

> I had to do
> signal(SIGINT, exit)
> to generate the behavior I wanted...

> In the posix specs, I didn't see an explanation of what SIG_DFL is supposed
> to do...

From the atext() man page:

        ... atexit() adds the function func() to a list of functions  to
     be  called  without  arguments  on normal termination of the
     program.  ...

From POSIX.1 (Table 3-1 - Required Signals):

        Symbolic        Default         Description
        Constant        Action
        ...             ...             ...
        SIGTERM         1               Termination signal.
        ...             ...             ...

        And note '1', says:

        1       Abnormal termination of the program.

I think the key words here are 'Abnormal' and 'normal' termination.

 
 
 

what should SIGINT default to?

Post by Lawrence Kirb » Thu, 06 Jul 1995 04:00:00




Quote:>The glibc manual says:
>Macro: int SIGTERM

>The SIGTERM signal is a generic signal used to cause program termination.
> Unlike SIGKILL,
>this signal can be blocked, handled, and ignored. It is the normal way to
> politely ask a program to
>terminate.

>The shell command kill generates SIGTERM by default.

>SIGTERM doesn't invoke exit, so any atexit()
>isn't processed...is this correct?

>I had to do
>signal(SIGINT, exit)
>to generate the behavior I wanted...

>In the posix specs, I didn't see an explanation of what SIG_DFL is supposed
>to do...

It is simply unsafe for either you or the implementation to call exit from
within (or even simply as) a signal handler. The problem is that exit can
call code which is not reentrant. For instance it closes open files. If the
signal happened when the foreground process was, say, executing a fprintf
function the FILE structure could at that instant be in a highly
inconsistent state making the results of the close unpredictable. The problem
is worse with atexit because user functions are involved which the
implementation has no control over.

All you should ever do in a signal hander is call functions guaranteed to be
reentrant and update (preferably volatile sig_atomic_t) variables and have the
foreground code test them at suitable points. Signals may in some instances
interrupt system calls and you can test for that too.

Using signals correctly is not trivial.

--
-----------------------------------------


-----------------------------------------

 
 
 

1. handling SIGINT in shell scripts when executing another shell script.

I have a simple shell script foo1.sh that invokes another shell script
foo2.sh, something like below:

#!/bin/sh
SIGINT_handler()
{
  echo "## [$DATE_TIME]  User interrupt ignored,"
  continue
trap SIGINT_handler 2

...
./foo2.sh
...

----------
while executing foo1.sh, if the script receives SIGINT, how do I ignore
the SIGINT in foo2.sh ? somehow foo2.sh does not finish to completion
and is killed after receiving SIGINT. but foo1.sh is still executing.
Is there any way to trap this signal in the child script. ? Please
share your thots and inputs on this topic.
Regards,
Vikram Shekhar

2. IPX over Linux PPP?

3. SIGINT signal

4. does anyone the s3

5. linuxthread manager and SIGINT

6. error message during booting

7. signals SIGINT SIGQUIT

8. Need HELP! Experts on Linux installation, please!

9. sigint while in non-canonical mode

10. Telnet Break and SIGINT

11. xterm & SIGINT

12. Parent process also terminating after killing child process in SIGINT

13. Raising a SIGINT when break is detected