lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 03 Apr 2014 13:13:44 +0200
From:	"Ulrich Windl" <Ulrich.Windl@...uni-regensburg.de>
To:	<linux-kernel@...r.kernel.org>
Subject: Q: setting the process name for ps

Hi!

Currently one has to fiddle with argv[] in-place when trying to change the process name "cmd") in Linux. However if you want to change the thread name ("comm"), there is a syscall (prctl(PR_SET_NAME, ...)) for it.

For comparison, in HP-UX there is also a syscall to change the process name for ps:
---
#include        <sys/pstat.h>

union pstun     psu;

psu.pst_command = "foobar";
pstat(PSTAT_SETCMD, psu, strlen("foobar") - 1, 0, 0);
---

To be fair, HP-XU also has syscalls to get processes, threads and arguments:
pstat_getlwp()
pstat_getproc()
pstat_getcommandline()

As Linux is different, I wonder whether there are any plans to provide a syscall to change the process name.

For those who aren't afraid of ugly code, here's a quick-and-dirty example how to change the process name in Linux (apologies, you guys know, but those who Google may not:
---
#include        <stdlib.h>
#include        <stdio.h>
#include        <string.h>
#include        <unistd.h>
#include        <time.h>

static  int     delay(void)
{
        struct timespec ts;

        ts.tv_sec = 10;
        ts.tv_nsec = 0;
        return nanosleep(&ts, NULL);
}

int     main(int argc, char *argv[])
{
        int             l = strlen(argv[0]);

        if ( argc > 1 )
                l += 1 + strlen(argv[1]);
        if (l  < 20 ) {
                printf("provide a long argument\n");
                return 1;
        }
        printf("look: unchanged\n"); delay();
        sprintf(argv[0], "proc %d", getpid());
        printf("look: process title\n"); delay();
        return 0;
}
---

As I'm not subscribed to LKML, please keep me CC'd on you replies!

Thanks & regards,
Ulrich Windl


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

Powered by blists - more mailing lists