From 344387c40e0de2e0fb24c32ffd790bb2b3af4428 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 21 Apr 2017 01:02:25 +0000 Subject: [PATCH] iscsi-scstd: replace signal() with sigaction() Replace signal() with sigaction() for validity in a multithreaded process Signed-off-by: David Butterfield git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7139 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/usr/iscsi_scstd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index 7fa813d04..d66943087 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -846,8 +846,13 @@ int main(int argc, char **argv) /* * Otherwise we could die in some later write() during the event_loop() * instead of getting EPIPE! + * + * The effects of signal(2) in a multithreaded process are unspecified, + * so use sigaction(2) instead. */ - signal(SIGPIPE, SIG_IGN); + struct sigaction act = (struct sigaction) { .sa_handler = SIG_IGN }; + int rc = sigaction(SIGPIPE, &act, NULL); + assert(rc == 0); while ((ch = getopt_long(argc, argv, "c:fd:s:u:g:a:p:vh", long_options, &longindex)) >= 0) { switch (ch) {