NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/48892: some tests will not clean up rump server processes
The attached patch teaches rump_server to respect an environment
variable RUMPDAEMON_KEEPSESSION so that it does not do setsid (just
setting the variable is enough, any value will do).
That way, when atf kills the test process's process group (which it
already does), it will kill any rump_server processes spawned by the
test.
I haven't patched all of the several hundred uses of rump_server
throughout src/tests to set it. But, until that is done, you could
test this patch by running the tests with
RUMPDAEMON_KEEPSESSION= atf-run
and see if the troublesome stress-killers still leave rump_servers
around.
Another alternative -- kludgier but perhaps more effective since it
covers more than just rump_server -- would be to LD_PRELOAD a library
that overrides:
pid_t setsid(void) { return getpid(); }
# HG changeset patch
# User Taylor R Campbell <riastradh%NetBSD.org@localhost>
# Date 1745629371 0
# Sat Apr 26 01:02:51 2025 +0000
# Branch trunk
# Node ID 0651c236b598cad1b91312f3fce68600bdec9095
# Parent fa66a8de28195fb9d8985a1c997f6a4b3fd8da4d
# EXP-Topic riastradh-pr48892-atfservers
rump: New environment variable RUMPDAEMON_KEEPSESSION.
If defined, the server will remain in the same session and process
group as the caller when it daemonizes.
This way, we can define it during test runs so that all the
rump_server processes are in the same process group as the atf test
itself -- and so even if the cleanups fail, when atf kills the
process group with killpg, the servers should terminate more
reliably
PR bin/48892: some tests will not clean up rump server processes
diff -r fa66a8de2819 -r 0651c236b598 lib/librumpuser/rumpuser_daemonize.c
--- a/lib/librumpuser/rumpuser_daemonize.c Thu Apr 24 18:37:59 2025 +0000
+++ b/lib/librumpuser/rumpuser_daemonize.c Sat Apr 26 01:02:51 2025 +0000
@@ -112,7 +112,8 @@ rumpuser_daemonize_begin(void)
switch (fork()) {
case 0:
- if (setsid() == -1) {
+ if (getenv("RUMPDAEMON_KEEPSESSION") == NULL &&
+ _setsid() == -1) {
rumpuser_daemonize_done(errno);
}
rv = 0;
diff -r fa66a8de2819 -r 0651c236b598 usr.bin/rump_allserver/rump_allserver.1
--- a/usr.bin/rump_allserver/rump_allserver.1 Thu Apr 24 18:37:59 2025 +0000
+++ b/usr.bin/rump_allserver/rump_allserver.1 Sat Apr 26 01:02:51 2025 +0000
@@ -211,6 +211,19 @@ After use,
.Nm
can be made to exit using
.Xr rump.halt 1 .
+.Sh ENVIRONMENT
+The following environment variables affect
+.Nm rump_server
+and
+.Nm rump_allserver :
+.Bl -tag -width Ev
+.It Ev RUMPDAEMON_KEEPSESSION
+If defined, the server will remain in the same session and process
+group as the caller when it daemonizes.
+By default, when the server daemonizes it will enter a new session and
+process group as with
+.Xr setsid 2 .
+.El
.Sh EXAMPLES
Start a server and load the tmpfs file system module, and halt the
server immediately afterwards:
Home |
Main Index |
Thread Index |
Old Index