[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] posix-extras: allow to set process title displayed by ps
From: |
Andy Bennett |
Subject: |
[Chicken-users] posix-extras: allow to set process title displayed by ps(1) |
Date: |
Mon, 13 Oct 2014 19:10:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.8.1 |
Hi,
Alex Charlton & I worked through how to set the process name as
displayed by ps(1).
This might be a useful addition to the posix-extras egg.
-----
(define (set-proc-title str)
(receive (c v) (argc+argv)
((foreign-lambda* void ((c-string str) (c-pointer argv))
"char *name = ((char**) argv)[0];
strncpy(name,str,strlen(name));
")
str v)))
-----
The actual implementation above is the work of Alex.
The implementation only allows to set the title to a string less than or
equal to the thing it's currently set to. This is fine for a single call
at fork() time: it's not possible to get a longer title using this
method anyway.
If a process wants to use the entirety of the buffer for any call, even
if the current value is shorter than the buffer then some extra magic
will be needed, such as stashing the original value in a static variable
or padding the passed in value with spaces.
Regards,
@ndy
--
address@hidden
http://www.ashurst.eu.org/
0x7EBA75FF
- [Chicken-users] posix-extras: allow to set process title displayed by ps(1),
Andy Bennett <=