[PATCH] 2.3.99-pre1: support setproctitle(3)

From: Nick Holloway (Nick.Holloway@alfie.demon.co.uk)
Date: Mon Mar 20 2000 - 16:36:00 EST


Here is a change to proc_pid_cmdline so that applications that attempt to
present their current state to ps(1) using some variant of setproctitle(3)
work in the same manner under 2.3 as they do under 2.2.

Whereas 2.2 would look into the environment area to return the full
information available from setproctitle(3), 2.3 only looks the area set
aside for the arguments.

This patch uses the following heuristic. If the nul byte at the end
of the argument area has been overwritten, then setproctitle(3) is
being used. If there is no nul in the argument area, then the contents
of environment area up to the first nul is also included.

If the argument area is not modified, then the only overhead is checking
a byte in the buffer to be returned to the user. It is not possible to
get /proc/$$/cmdline to look outside the argument and environment space,
nor to return more than 1 page of data. I've left /proc/$$/environ
to return random garbage if setproctitle(3) is being used -- behaviour
compatable with 2.2.

I've given this a quick workout using assignments to $0 in Perl. I'd like
others to have a look at this and try it out, and see how it works with
their favorite applications.

-- 
 `O O'  | Nick.Holloway@alfie.demon.co.uk
// ^ \\ | http://www.alfie.demon.co.uk/


- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:31 EST