]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Print "invalid option -- z" when it is
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 8 Apr 2025 07:37:17 +0000 (09:37 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 9 Apr 2025 05:48:54 +0000 (07:48 +0200)
It can only be used if defined(HAVE_FORK) || defined(HAVE_VFORK).
e.g. not on Windows systems.

Update print_usage().

Update the man page.

(backported from commit 43064ae5a5e9f882b62d7270bfff675f742702e4)

tcpdump.1.in
tcpdump.c

index 1a32945f71fae78eaa4e54b237bfea87ac421cf7..52305db265a768c12a692f14b66753df63120ccc 100644 (file)
@@ -964,6 +964,8 @@ or
 .B \-z bzip2
 will compress each savefile using gzip or bzip2.
 .IP
+This option can only be used if fork subprocess is implemented (e.g. not on Windows systems).
+.IP
 Note that tcpdump will run the command in parallel to the capture, using
 the lowest priority so that this doesn't disturb the capture process.
 .IP
index 86881fdd92d9124a983b6ab3010271917e9103a8..24ac28ee13674c3b15c2db357a8b5aeca2312b90 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -673,7 +673,15 @@ show_remote_devices_and_exit(void)
 #define U_FLAG
 #endif
 
-#define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:s:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#"
+#if defined(HAVE_FORK) || defined(HAVE_VFORK)
+#define z_FLAG         "z:"
+#define z_FLAG_USAGE    "[ -z postrotate-command ] "
+#else
+#define z_FLAG
+#define z_FLAG_USAGE
+#endif
+
+#define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:s:StT:u" U_FLAG "vV:w:W:xXy:Y" z_FLAG "Z:#"
 
 /*
  * Long options.
@@ -2122,13 +2130,12 @@ main(int argc, char **argv)
                        }
                        break;
 #endif
-               case 'z':
+
 #if defined(HAVE_FORK) || defined(HAVE_VFORK)
+               case 'z':
                        zflag = optarg;
-#else
-                       error("-z cannot be used. Fork subprocess not implemented.");
-#endif
                        break;
+#endif
 
                case 'Z':
                        username = optarg;
@@ -3534,5 +3541,5 @@ print_usage(FILE *f)
 "\t\t[ --time-stamp-precision precision ] [ --micro ] [ --nano ]\n");
 #endif
        (void)fprintf(f,
-"\t\t[ -z postrotate-command ] [ -Z user ] [ expression ]\n");
+"\t\t" z_FLAG_USAGE "[ -Z user ] [ expression ]\n");
 }