Aggiornamento note copyright
[gapil.git] / sources / test_signalfd.c
index 628bd4d85bb6519feea6416ff139e9d33b834c0a..a31cf0b27a847f7b9f324461736ebbaaccac5797 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
 /* 
  * Variables definition  
  */
-    int i, nomask, testwrite, sigfd;
+    int i, n, nomask=0, testwrite=0, sigfd;
     time_t t;
     struct signalfd_siginfo siginf;
     sigset_t sigmask;
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
        case 'n':   /* no mask option */
            nomask = 1;
            break;
-       case 'w':   /* no mask option */
+       case 'w':   /* testwrite option */
            testwrite = 1;
            break;
        case '?':   /* unrecognized options */
@@ -104,9 +104,10 @@ int main(int argc, char *argv[])
        die("Failing in signalfd");
     printf("Signalfd armed\n");
     if (testwrite) {
-       if (write(sigfd, buffer, sizeof(buffer)))
+       if ( (n=write(sigfd, buffer, sizeof(buffer))) < 0)
            perror("write on signal fd error");
-       else printf("write successfully\n");        
+       else
+           printf("write successfully %d bytes\n", n);     
     }
     /* raise signal */
     if (raise(SIGINT) != 0)
@@ -127,7 +128,7 @@ int main(int argc, char *argv[])
 void usage(void) {
     printf("Program testsignalfd : test signalfd on close \n");
     printf("Usage:\n");
-    printf("  testfopen [-h] file mode \n");
+    printf("  testsignalfd [-h] file mode \n");
     printf("  -h          print this help\n");
     
     exit(1);