what is maxcmdlen? $0 len?

Michael Scheidell scheidell at freebsd.org
Thu Jan 26 15:39:23 UTC 2012

(followups set to ports@)

I am trying to track down a persistent bug in swatch.
swatch sets y $commandLineString = $0 . ' ' . join(' ', @ARGV);

, and if the len of the cmdargs is > (x?), then ps gets borked, rc 
scripts can't find it (so service status won't work), service restart 
won' t kill old one, so it just keep adding new instances.

perldoc says:

"Note that there are platform-specific limitations on the maximum length 
of $0 . In the most extreme case it may be limited to the space occupied 
by the original $0 ."

(but, I searched and could not find it)

best I can tell, this number is 251. (possibly 255)

(in swatch.rc, swatch_flags -gt 222 chars), so, swatch_flags, then len 
of command (/usr/local/bin/swatch), some spacing, the '(perl)' at end...
and something else.

other than putting something like this in rc file, is there a way to 
tell, on a platform by platform basis, what this number is?

should I send patches to swatch upstream to prevent this from happening?


swatch_1_flags='-c /usr/local/etc/swatch-hackertrap.conf 
--tail-args=-Fn0 --daemon --script-dir=/tmp/  

ps -auxww | grep swatch
root       86920  0.0  0.7  7496  6960  ??  Is    9:33AM   0:00.01 
/usr/local/bin/perl /tmp//.swatch_script.86918

  ./swatch status
swatch is not running.

  ./swatch status
swatch is not running.

  ./swatch status
  swatch is running as pid 98668.

Michael Scheidell, CTO
o: 561-999-5000
d: 561-948-2259
 >*| *SECNAP Network Security Corporation

    * Best Mobile Solutions Product of 2011
    * Best Intrusion Prevention Product
    * Hot Company Finalist 2011
    * Best Email Security Product
    * Certified SNORT Integrator

More information about the freebsd-ports mailing list