-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBSD 12.1: setproctitle() has no effect #94
Comments
What happens if you try running your test python script using the What is you |
See below, find_argv_from_env() bails out. The sys.platform is freebsd12.
|
That's weird, isn't it? And the distance between arg[0] and env is 7 bytes, which is consistent with "python\x00" why does this strcmp doensn't return 0? if (strcmp(ptr, arg0)) {
spt_debug("argv[0] doesn't match '%s'", arg0);
goto exit;
} could you please try to apply this patch: diff --git a/src/spt_setup.c b/src/spt_setup.c
index 8953786..17597f7 100644
--- a/src/spt_setup.c
+++ b/src/spt_setup.c
@@ -213,7 +213,7 @@ find_argv_from_env(int argc, char *arg0)
goto exit;
}
if (strcmp(ptr, arg0)) {
- spt_debug("argv[0] doesn't match '%s'", arg0);
+ spt_debug("argv[0] '%s' doesn't match '%s'", ptr, arg0);
goto exit;
}
and tell what is the debug output? Thank you! |
ptr is an empty string: [SPT]: argv[0] '' doesn't match 'python' (meanwhile I'm trying to get my head around the reverse pointer scan; Let me know where I can add more debugging) |
I don't know, the problems seem there around. Can you dump the numeric value of the chars between argv[0] and environ? |
no issues here when argv > 1:
|
I have next to no C skills, so here goes.. Looks like just NULL's. --- /jails/data/edp-staging/tmp/setproctitle-1.2.1/src/spt_setup.c.orig 2020-12-18 18:23:45.612310000 +0100
+++ /jails/data/edp-staging/tmp/setproctitle-1.2.1/src/spt_setup.c 2020-12-18 20:38:44.522783000 +0100
@@ -182,6 +182,19 @@
goto exit;
}
spt_debug("found environ at %p", ptr);
+
+ spt_debug(".first env is: %s", ptr);
+ {
+ char *pptr;
+ size_t j;
+ for (j = 0; j < strlen(arg0); j++) {
+ pptr = ptr - 1 - j;
+ spt_debug(".ptr %p val: %i", pptr, *pptr);
+ }
+ pptr--;
+ spt_debug(".ptr %p val: %i", pptr, *pptr);
+ }
+
limit = ptr - ARG_MAX;
--ptr;
for (i = argc - 1; i >= 1; --i) {
|
Would you be so kind to check what happened instead with setproctitle 1.1? Thank you very much |
Sorry it took a while since my last comment. It's been a bit busy in my life. Meanwhile the jail I where I was testing this issue has been upgraded from python3.7 to python3.9. I've repeated the earlier steps with the same results. And now also with 1.1.10: The previous version gives the exact same complaints as 1.2, but... it works:
|
Some more observations:
python -c 'import setproctitle; setproctitle.setproctitle("helloworld"); import time; time.sleep(2)' &
sleep 1
ps -x -o pid,command yields
Fixes
I will soon make a PR with these fixes. |
Closed by #99, to be released in 1.3.0. |
I just upgraded setproctitle from 1.1.10 to 1.2.1 and get the impression that it stopped working.
The changesets from issue #67 seems to set more macro defines than in the past. And src/spt_status.c does lots of things with macros... sooo, yes, maybe different things happen than in the previous situation. I find it hard to comprehend the various ifdef/define combinations.
FreeBSD 12 supports setproctitle(3) (in unistd.h).
The text was updated successfully, but these errors were encountered: