about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-06-13 14:27:34 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-06-13 14:27:34 +0200
commit38c2ac045171670992ecc709f937078a13deec72 (patch)
tree14dd2beecd1097d0fe5cab0ec5596f1579c77e54
parent439ea6f9f36aacd80c8d50fdfb59c375daf40637 (diff)
downloadextrace-38c2ac045171670992ecc709f937078a13deec72.tar.gz
extrace-38c2ac045171670992ecc709f937078a13deec72.tar.xz
extrace-38c2ac045171670992ecc709f937078a13deec72.zip
axe -w and make it default
Use cut(1) if you want to limit the line length.
-rw-r--r--extrace.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/extrace.c b/extrace.c
index 4f5dc7c..22194ee 100644
--- a/extrace.c
+++ b/extrace.c
@@ -3,12 +3,11 @@
  * Requires CONFIG_CONNECTOR=y and CONFIG_PROC_EVENTS=y.
  * Requires root or "setcap cap_net_admin+ep extrace".
  *
- * Usage: extrace [-d] [-f] [-w] [-o FILE] [-p PID|CMD...]
+ * Usage: extrace [-d] [-f] [-o FILE] [-p PID|CMD...]
  * default: show all exec(), globally
  * -p PID   only show exec() descendant of PID
  * CMD...   run CMD... and only show exec() descendant of it
- * -o FILE  log to FILE instead of standard output (implies -w)
- * -w       wide output: show full command line
+ * -o FILE  log to FILE instead of standard output
  * -f       flat output: no indentation
  * -l       print full path of argv[0]
  * -d       print cwd of process
@@ -83,7 +82,6 @@
 
 #define CMDLINE_MAX 32768
 pid_t parent = 1;
-int width = 80;
 int flat = 0;
 int run = 0;
 int full_path = 0;
@@ -184,14 +182,14 @@ handle_msg(struct cn_msg *cn_hdr)
     }
 
     if (full_path && r2 > 0)
-      snprintf(buf, min(sizeof buf, width+1),
+      fprintf(output,
                "%*s%d %s%s%s%s", flat ? 0 : 2*d, "",
                ev->event_data.exec.process_pid,
                show_cwd ? cwd : "", show_cwd ? " % " : "",
                exe,
                argvrest);
     else
-      snprintf(buf, min(sizeof buf, width+1),
+      fprintf(output,
                "%*s%d %s%s%s", flat ? 0 : 2*d, "",
                ev->event_data.exec.process_pid,
                show_cwd ? cwd : "", show_cwd ? " % " : "",
@@ -214,11 +212,6 @@ main(int argc, char *argv[])
   size_t recv_len = 0;
   int rc = -1, opt;
 
-  if (getenv("COLUMNS"))
-    width = atoi(getenv("COLUMNS"));
-  if (width <= 0)
-    width = 80;
-
   output = stdout;
 
   while ((opt = getopt(argc, argv, "+dflo:p:qw")) != -1)
@@ -234,8 +227,8 @@ main(int argc, char *argv[])
         perror("fopen");
         exit(1);
       }
-      /* FALLTROUGH */
-    case 'w': width = CMDLINE_MAX; break;
+      break;
+    case 'w': /* obsoleted, ignore */; break;
     default: goto usage;
     }