Saturday, June 02, 2018

pgrep/pkill in rc script

I have a 6.3 machine running four Minecraft instances (i.e. Java apps).
I recently changed the rc script for one of them to use additional Java
command-line arguments. I believe I ran into something similar to
https://marc.info/?l=openbsd-misc&m=138268000201733, where pgrep would
no longer match the command arguments since it was longer than 16
characters (although in my case it didn't match either from script or
shell). However, the 16-character limit doesn't seem right, because my
old command was already longer.

Old command:
/usr/local/jre-1.8.0/bin/java -Xms1536M -Xmx1536M -jar
/var/games/minecraft/minecraft_server.jar nogui

New command:
/usr/local/jre-1.8.0/bin/java -server -Xms1536M -Xmx1536M
-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing
-XX:ParallelGCThreads=2 -XX:+AggressiveOpts -jar
/var/games/minecraftss/minecraft_server.jar nogui

So, with the old command, it's only comparing "-Xms1536M -Xmx" at 16
characters (or /usr/local/jre if it's referring to the executable), so I
would think it wouldn't have worked with the old command, either.

Fortunately, I was already running the four as different users, so I
could work around it by using pgrep/pkill -U. However, I'm curious
about the 16-character limit; I looked at the source for pkill, and the
only limit I saw was _POSIX2_LINE_MAX. Or was the limit a red herring,
and something else was causing my problem?

Thanks.

No comments:

Post a Comment