Skip to contentSkip to conversation

Question about Linux signal handling

DISCUSSION Albert Cahalan 3 participants 5 messages Feb 23, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines · Tom Sanders

If I catch a signal (SIGUSR2) using "sigaction" call then is the signal handler replaced with default handling, if I don't install the signal handler again?

That depends on how you set sa_flags. Read the sigaction man page.

Quoted 3 lines

I remember that in UNIX "signal" system call default signal bahavior was to replace the signal handler with default after everytime signal was received?

Yes. This is the behavior of all SysV UNIX systems and Linux kernels. Unfortunately, BSD got it wrong. Worse, the glibc developers saw fit to ignore both UNIX history and Linus. They implemented BSD behavior by making signal() use the sigaction system call instead of the signal system call. This of course makes it harder to port apps from SysV UNIX systems to Linux. Use sigaction() in all new code.

#1 lore raw
Quoted 2 lines · Albert Cahalan

Yes. This is the behavior of all SysV UNIX systems and Linux kernels. Unfortunately, BSD got it wrong.

Firstly BSD didn't get it wrong, things merely diverged historically after V7 unix.

Quoted 3 lines

Worse, the glibc developers saw fit to ignore both UNIX history and Linus. They implemented BSD behavior by making signal() use the sigaction system call

Also wrong. If you read the gcc documentation you can select favouring BSD or SYS5 behaviour at compile time

glibc has the best of both worlds

#2 lore raw
Quoted 7 lines · Alan Cox
Quoted 2 lines · Albert Cahalan

Yes. This is the behavior of all SysV UNIX systems and Linux kernels. Unfortunately, BSD got it wrong.

Firstly BSD didn't get it wrong, things merely diverged historically after V7 unix.

BSD is wrong for not choosing a different name for the new system call and leaving the old one. There could have been a signal2() with the new behavior. X/Open even did this, with bsd_signal() as the name. Breaking compatibility is bad.

Quoted 8 lines
Quoted 3 lines

Worse, the glibc developers saw fit to ignore both UNIX history and Linus. They implemented BSD behavior by making signal() use the sigaction system call

Also wrong. If you read the gcc documentation you can select favouring BSD or SYS5 behaviour at compile time

glibc has the best of both worlds

Non-default behavior is nearly irrelevant. The default should have matched traditional UNIX and Linux behavior.

The best of both worlds certainly means traditional signal() and a bsd_signal(), with a non-default option to choose the BSD signal() behavior.

#3 lore raw
Quoted 5 lines · Albert Cahalan
Quoted 2 lines

Firstly BSD didn't get it wrong, things merely diverged historically after V7 unix.

BSD is wrong for not choosing a different name
for the new system call and leaving the old one.

The same is true of System 5. Both of the changes semantics from V7 unix.

Quoted 4 lines
Quoted 1 line

glibc has the best of both worlds

Non-default behavior is nearly irrelevant. The default should have matched traditional UNIX and Linux behavior.

Its all in the docs, and to quote one of the smarter managerial people we had in Red Hat "I can only provide the information, I can't make you hear it."

Alan

#4 lore raw
In reply to Alan Cox

From: Alan Cox <[email protected]>
Subject: Re: Question about Linux signal handling
Date: 23 Feb 2003 23:43:31 +0000

Quoted 6 lines · Albert Cahalan
Quoted 2 lines

Yes. This is the behavior of all SysV UNIX systems and Linux kernels. Unfortunately, BSD got it wrong.

Firstly BSD didn't get it wrong, things merely diverged historically after V7 unix.

The V7 signals where not reliable and there where not neatly blockable. Naturally people invented incompatible solutions to come around it, just as you would expect.

Cheers,
Magnus - porting teaches you stuff you didn't want to know about