Re: [PATCH] Replace error prone signal() with sigaction()
From: Paul Menzel <hidden>
Date: 2022-02-08 11:26:08
Dear Mariusz, Am 08.02.22 um 10:52 schrieb Mariusz Tkaczyk:
On Tue, 8 Feb 2022 09:52:03 +0100 Paul Menzel wrote:
quoted
Am 08.02.22 um 16:29 schrieb Lukasz Florczak:quoted
Up to this date signal() was used which is deprecated [1]. Sigaction() call is preferred. This commit introduces replacement from signal() to sigaction() by the use of signal_s() wrapper. Also remove redundant signal.h header includes.signal(2) also says:quoted
* By default, in glibc 2 and later, the signal() wrapper function does not invoke the kernel system call. Instead, it calls sigaction(2) using flags that supply BSD semantics. This default behavior is pro‐ vided as long as a suitable feature test macro is defined: _BSD_SOURCE on glibc 2.19 and earlier or _DEFAULT_SOURCE in glibc 2.19 and later. (By default, these macros are defined; see fea‐ ture_test_macros(7) for details.) If such a feature test macro is not defined, then signal() provides System V semantics.Does that mean, it should still be replaced?
Both ways are correct. signal() is not deprecated but the behavior may vary. It can be avoided by sigaction(), so it is better to use sigaction() then. Do you agree?
I am not experienced enough to comment on this. But I am fine with this, if you could rephrase that in the commit message. Kind regards, Paul