]> granicus.if.org Git - strace/commitdiff
2003-01-21 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Fri, 24 Jan 2003 04:31:23 +0000 (04:31 +0000)
committerRoland McGrath <roland@redhat.com>
Fri, 24 Jan 2003 04:31:23 +0000 (04:31 +0000)
* strace.c (usage): Omit -z, since it has never worked properly.
* NEWS: Likewise.
* strace.c (main): Grok new option `-E var=val' or `-E var' to put
var=val in environ or to remove var, respectively.
(usage): Mention it.
* strace.1, NEWS: Document it.

NEWS
strace.c

diff --git a/NEWS b/NEWS
index 273e97a2430a9e01fc6ed6405b1edc8aea0cb122..7bb2c40177d45eec3f81bb0a447685c7f19efb73 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,9 @@
-Changes in 4.4.93 TEST release
+Changes in 4.4.94 TEST release
 ==============
 * New port to AMD's x86-64 architecture. One strace binary can
   handle both new x86-64 and old i386 processes.
 * Fixed support for LFS64 calls.
-* New switch (-z) for printing only non-failing syscalls.
+* New switch -E to add/remove environment variables for the command.
 * Merged s390/s390x port.
 * Trace an unbounded number of processes.
 * Handle numerous new system calls in Linux 2.5, and new threads semantics.
index a456efd24011cf0c1309ed82e380166556f09a82..6171245495fcaef0edfd099334feedc77aed24fc 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -136,8 +136,10 @@ int exitval;
 {
        fprintf(ofp, "\
 usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file]\n\
-              [-p pid] ... [-s strsize] [-u username] [command [arg ...]]\n\
-   or: strace -c [-e expr] ... [-O overhead] [-S sortby] [command [arg ...]]\n\
+              [-p pid] ... [-s strsize] [-u username] [-E var=val] ...\n\
+              [command [arg ...]]\n\
+   or: strace -c [-e expr] ... [-O overhead] [-S sortby] [-E var=val] ...\n\
+              [command [arg ...]]\n\
 -c -- count time, calls, and errors for each syscall and report summary\n\
 -f -- follow forks, -ff -- with output into separate files\n\
 -F -- attempt to follow vforks, -h -- print help message\n\
@@ -156,8 +158,12 @@ usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file]\n\
 -s strsize -- limit length of print strings to STRSIZE chars (default %d)\n\
 -S sortby -- sort syscall counts by: time, calls, name, nothing (default %s)\n\
 -u username -- run command as username handling setuid and/or setgid\n\
+-E var=val -- put var=val in the environment for command\n\
+-E var -- remove var from the environment for command\n\
+" /* this is broken, so don't document it
 -z -- print only succeeding syscalls\n\
-", DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY);
+  */
+, DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY);
        exit(exitval);
 }
 
@@ -200,7 +206,7 @@ char *argv[];
        set_sortby(DEFAULT_SORTBY);
        set_personality(DEFAULT_PERSONALITY);
        while ((c = getopt(argc, argv,
-               "+cdfFhiqrtTvVxza:e:o:O:p:s:S:u:")) != EOF) {
+               "+cdfFhiqrtTvVxza:e:o:O:p:s:S:u:E:")) != EOF) {
                switch (c) {
                case 'c':
                        cflag++;
@@ -260,7 +266,7 @@ char *argv[];
                        set_overhead(atoi(optarg));
                        break;
                case 'p':
-                       if ((pid = atoi(optarg)) == 0) {
+                       if ((pid = atoi(optarg)) <= 0) {
                                fprintf(stderr, "%s: Invalid process id: %s\n",
                                        progname, optarg);
                                break;
@@ -270,7 +276,7 @@ char *argv[];
                                break;
                        }
                        if ((tcp = alloctcb(pid)) == NULL) {
-                               fprintf(stderr, "%s: tcb table full, please recompile strace\n",
+                               fprintf(stderr, "%s: out of memory\n",
                                        progname);
                                exit(1);
                        }
@@ -286,6 +292,13 @@ char *argv[];
                case 'u':
                        username = strdup(optarg);
                        break;
+               case 'E':
+                       if (putenv(optarg) < 0) {
+                               fprintf(stderr, "%s: out of memory\n",
+                                       progname);
+                               exit(1);
+                       }
+                       break;
                default:
                        usage(stderr, 1);
                        break;