Package: xdiskusage / 1.48-10.1

04_xdiskusage.C_check_standard_input.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Author: Carles Pina i Estany <carles@pina.cat>
Description: see bug #276193
--- xdiskusage-1.48.orig/xdiskusage.C
+++ xdiskusage-1.48/xdiskusage.C
@@ -223,6 +223,19 @@
   return 1;
 }
 
+// returns true if stdin is /dev/null
+// To fix Debian bug #276193
+// Technically could be possible that returns "true" and is not "true",
+// because same device ID is used across file systems. But is the best
+// solutions that I have
+int isstdinnull() {
+        struct stat ststdin,stnull;
+        stat("/dev/null",&stnull);
+        fstat(0,&ststdin);
+
+        return (ststdin.st_rdev==stnull.st_rdev);
+}
+
 int main(int argc, char**argv) {
 #if FL_MAJOR_VERSION < 2
   // Make fltk look more like KDE/Windoze:
@@ -253,7 +266,7 @@
       OutputWindow* d = OutputWindow::make(argv[n++]);
       if (d) d->show(argc,argv);
     }
-  } else if (!isatty(0)) {
+  } else if (!isatty(0) && !isstdinnull()) {
     // test for pipe, if so read stdin:
     OutputWindow* d = OutputWindow::make(0);
     if (d) d->show(argc,argv);