dazuko-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dazuko-devel] [PATCH] adjust showfiles.c to new signal semantic


From: Lino Sanfilippo
Subject: [Dazuko-devel] [PATCH] adjust showfiles.c to new signal semantic
Date: Fri, 12 Nov 2010 13:39:12 +0100
User-agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100329)




Hi,

this patch adjusts the test program (showfiles.c) to the new signal semantic that is used by dazukofs. Without this the program may not be interruptable by SIGINT, SIGTERM and SIGHUP
(depending on the underlaying signal() call implementation).

It simply removes the unportable signal() with the portable sigaction() function.
It applies against dazukofs-3.1.4-rc3.

Regards,
Lino


Geschäftsführender Gesellschafter: Tjark Auerbach
Sitz der Gesellschaft: Tettnang
Handelsregister: Amtsgericht Ulm, HRB 630992
ALLGEMEINE GESCHÄFTSBEDINGUNGEN
Es gelten unsere Allgemeinen Geschäftsbedingungen
(AGB). Sie finden sie in der jeweils gültigen Fassung
im Internet unter http://www.avira.com/de/standard-terms-conditions-business-de
***************************************************
diff -Nurp dazukofs-3.1.4-rc3/test/showfiles.c 
dazukofs-3.1.4-rc3-PATCH1/test/showfiles.c
--- dazukofs-3.1.4-rc3/test/showfiles.c 2008-10-25 00:08:30.000000000 +0200
+++ dazukofs-3.1.4-rc3-PATCH1/test/showfiles.c  2010-11-12 13:26:26.000000000 
+0100
@@ -25,7 +25,7 @@
 #include <errno.h>
 #include <signal.h>
 
-static int running = 1;
+static volatile sig_atomic_t running = 1;
 
 static void print_access(struct dazukofs_access *acc)
 {
@@ -48,12 +48,26 @@ static void sigterm(int sig)
 
 int main(void)
 {
+       struct sigaction sa;
        dazukofs_handle_t hndl;
        struct dazukofs_access acc;
 
-       signal(SIGHUP, sigterm);
-       signal(SIGINT, sigterm);
-       signal(SIGTERM, sigterm);
+       memset(&sa, 0, sizeof(sa));
+
+       memset(&sa, 0, sizeof(sa));
+       sa.sa_handler = sigterm;
+       if (sigaction(SIGHUP, &sa, NULL)) {
+               perror("install SIGHUP handler");
+               return -1;
+       }
+       if (sigaction(SIGINT, &sa, NULL)) {
+               perror("install SIGINT handler");
+               return -1;
+       }
+       if (sigaction(SIGTERM, &sa, NULL)) {
+               perror("install SIGTERM handler");
+               return -1;
+       }
 
        hndl = dazukofs_open("dazukofs_example", DAZUKOFS_TRACK_GROUP);
        if (!hndl) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]