Index | Thread | Search

From:
Mikolaj Kucharski <mikolaj@kucharski.name>
Subject:
Bump buffer size in pkill's getargv() function
To:
tech@openbsd.org
Date:
Fri, 27 Feb 2026 13:46:52 +0000

Download raw body.

Thread
Hi,

I am facing a problem with pgrep'ing Java daemon, which has long list of
arguments.

Current situation is:

# rcctl check signal_daemon
signal_daemon(failed)

# pgrep -lf java | wc -c
    2540

As you can see, that list of arguments is longer than _POSIX2_LINE_MAX
which is currently used by pkill / pgrep command.

$ getconf _POSIX2_LINE_MAX
2048

With following pexp defined:

# grep -w pexp /etc/rc.d/signal_daemon
pexp="${JAVA}.* org.asamk.signal.Main daemon${daemon_flags:+ ${daemon_flags}}"

the regex is not able to match very end of the Java arguments, because
the buffer is too small.

I am bumping the buffer to:

$ getconf _POSIX_ARG_MAX
4096

which makes rc.d(8) script work:

# rcctl check signal_daemon
signal_daemon(ok)

This is minimal diff, to make things good enough.


diff --git usr.bin/pkill/pkill.c usr.bin/pkill/pkill.c
index c9ed8cc9e3b..7b3471d1c83 100644
--- usr.bin/pkill/pkill.c
+++ usr.bin/pkill/pkill.c
@@ -113,7 +113,7 @@ extern char *__progname;
 static char *
 getargv(struct kinfo_proc *kp)
 {
-	static char buf[_POSIX2_LINE_MAX];
+	static char buf[_POSIX_ARG_MAX];
 	char **pargv;
 	size_t j;
 

-- 
Regards,
 Mikolaj