xfs
[Top] [All Lists]

[PATCH 2/2] xfsprogs: Use Posix signal API signprocmask instead of sigre

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/2] xfsprogs: Use Posix signal API signprocmask instead of sigrelse/sighold in xfs_copy.c
From: "Kamal Dasu" <kdasu.kdev@xxxxxxxxx>
Date: Thu, 1 Mar 2012 16:11:25 -0500
Cc: "Kamal Dasu" <kdasu.kdev@xxxxxxxxx>
In-reply-to: <de74feb44ebd887269fe85d9a5879765afccf4c2.1330635228.git.kdasu.kdev@xxxxxxxxx>
References: <de74feb44ebd887269fe85d9a5879765afccf4c2.1330635228.git.kdasu.kdev@xxxxxxxxx>
>From sigrelse and sighold man page

DESCRIPTION
       These  functions are provided in glibc as a compatibility interface for
       programs that make use of the historical System V signal API.  This API
       is  obsolete:  new applications should use the POSIX signal API (sigac‐
       tion(2), sigprocmask(2), etc.)

Signed-off-by: Kamal Dasu <kdasu.kdev@xxxxxxxxx>
---
 copy/xfs_copy.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index c01e0b9..69c85bd 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -71,6 +71,17 @@ xfs_off_t write_log_header(int fd, wbuf *w, xfs_mount_t *mp);
 #define PRE    0x08            /* append strerror string */
 #define LAST   0x10            /* final message we print */
 
+
+void
+signal_maskfunc(int addset, int newset) 
+{
+       sigset_t set;
+
+       sigemptyset(&set);
+       sigaddset(&set, addset);
+       sigprocmask(newset, &set, NULL);
+}
+
 void
 do_message(int flags, int code, const char *fmt, ...)
 {
@@ -478,9 +489,9 @@ write_wbuf(void)
                if (target[i].state != INACTIVE)
                        pthread_mutex_unlock(&targ[i].wait);    /* wake up */
 
-       sigrelse(SIGCHLD);
+       signal_maskfunc(SIGCHLD, SIG_UNBLOCK);
        pthread_mutex_lock(&mainwait);
-       sighold(SIGCHLD);
+       signal_maskfunc(SIGCHLD, SIG_BLOCK);
 }
 
 
@@ -847,7 +858,7 @@ main(int argc, char **argv)
        /* set up sigchild signal handler */
 
        signal(SIGCHLD, handler);
-       sighold(SIGCHLD);
+       signal_maskfunc(SIGCHLD, SIG_BLOCK);
 
        /* make children */
 
-- 
1.7.5.4


<Prev in Thread] Current Thread [Next in Thread>