Skip to content

Commit 43064ae

Browse files
committed
Print "invalid option -- z" when it is
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.
1 parent cd22080 commit 43064ae

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

tcpdump.1.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,8 @@ or
10341034
.B \-z bzip2
10351035
will compress each savefile using gzip or bzip2.
10361036
.IP
1037+
This option can only be used if fork subprocess is implemented (e.g. not on Windows systems).
1038+
.IP
10371039
Note that tcpdump will run the command in parallel to the capture, using
10381040
the lowest priority so that this doesn't disturb the capture process.
10391041
.IP

tcpdump.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,15 @@ show_remote_devices_and_exit(void)
616616
#define m_FLAG_USAGE "[ -m module ] ..."
617617
#endif
618618

619-
#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:#"
619+
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
620+
#define z_FLAG "z:"
621+
#define z_FLAG_USAGE "[ -z postrotate-command ] "
622+
#else
623+
#define z_FLAG
624+
#define z_FLAG_USAGE
625+
#endif
626+
627+
#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:#"
620628

621629
/*
622630
* Long options.
@@ -2014,13 +2022,12 @@ main(int argc, char **argv)
20142022
}
20152023
break;
20162024
#endif
2017-
case 'z':
2025+
20182026
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
2027+
case 'z':
20192028
zflag = optarg;
2020-
#else
2021-
error("-z cannot be used. Fork subprocess not implemented.");
2022-
#endif
20232029
break;
2030+
#endif
20242031

20252032
case 'Z':
20262033
username = optarg;
@@ -3484,5 +3491,5 @@ print_usage(FILE *f)
34843491
"\t\t[ --time-stamp-precision precision ] [ --micro ] [ --nano ]\n");
34853492
#endif
34863493
(void)fprintf(f,
3487-
"\t\t[ -z postrotate-command ] [ -Z user ] [ expression ]\n");
3494+
"\t\t" z_FLAG_USAGE "[ -Z user ] [ expression ]\n");
34883495
}

0 commit comments

Comments
 (0)