]> 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)
committerfxlb <[email protected]>
Wed, 9 Apr 2025 05:40:46 +0000 (05:40 +0000)
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.

tcpdump.1.in
tcpdump.c

index 4aa65016d1d93e2458dcab87aba7628bf71a0209..988339764b1697b0d07de61ece1ef8a128364369 100644 (file)
@@ -1034,6 +1034,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 01de8634f9bea632a36e31578f169d178a8e2413..f8b6f537a840b9c3ffb73b7f81c65832c1cae21b 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -616,7 +616,15 @@ show_remote_devices_and_exit(void)
 #define m_FLAG_USAGE "[ -m module ] ..."
 #endif
 
-#define SHORTOPTS "aAbB:c:C:dDeE:fF:G:hHi:I" j_FLAG J_FLAG "KlLm:M:nNOpqQ:r:s:StT:uUvV: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 "aAbB:c:C:dDeE:fF:G:hHi:I" j_FLAG J_FLAG "KlLm:M:nNOpqQ:r:s:StT:uUvV:w:W:xXy:Y" z_FLAG "Z:#"
 
 /*
  * Long options.
@@ -2014,13 +2022,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;
@@ -3484,5 +3491,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");
 }