diff -Naur a/lib/lib.c b/lib/lib.c
--- a/lib/lib.c	2014-10-02 18:23:27.000000000 +0530
+++ b/lib/lib.c	2014-10-06 16:59:34.000000000 +0530
@@ -511,8 +511,7 @@
 
   // Set permissions of output file
 
-  fstat(fdin, &statbuf);
-  fchmod(fd, statbuf.st_mode);
+  if (!fstat(fdin, &statbuf)) fchmod(fd, statbuf.st_mode);
 
   return fd;
 }
@@ -668,7 +667,7 @@
     if (!strncasecmp(pidstr, "sig", 3)) pidstr+=3;
   }
   for (i = 0; i < sizeof(signames)/sizeof(struct signame); i++)
-    if (!pidstr) xputs(signames[i].name);
+    if (!pidstr) xprintf("%02d) %s\n", signames[i].num, signames[i].name);
     else if (!strcasecmp(pidstr, signames[i].name)) return signames[i].num;
 
   return -1;
@@ -747,7 +746,7 @@
         if (i == 3) {
           // suid/sticky bit.
           if (j) {
-            if ((dowhat & 8) && (dowho&(8|(1<<i)))) bit++;
+            if ((dowhat & 8) && (dowho&(8|(1<<j)))) bit++;
           } else if (dowhat & 16) bit++;
         } else {
           if (!(dowho&(8|(1<<i)))) continue;
@@ -829,7 +828,7 @@
 
   len = sprintf(buf, "%lld", num);
   end = ((len-1)%3)+1;
-  len /= 3;
+  len = (len -1)/3;
 
   if (len && end == 1) {
     buf[2] = buf[1];
