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

-- 
[email protected]
http://www.ashurst.eu.org/
0x7EBA75FF


_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to