Skip to contentSkip to conversation

Change processname for dmix/dsnoop process

DISCUSSION Gregor Jasny 3 participants 11 messages Sep 30, 2005 – Oct 5, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

At the moment the dmix process inherits the processname from the first dmix enabled process. This can be very confusing.

It would be nice if dmix or dsnoop would change its name after forking.

Thanks,
Gregor

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#1 lore raw

At Fri, 30 Sep 2005 16:18:02 +0200,

Quoted 7 lines · Gregor Jasny

Hi,

At the moment the dmix process inherits the processname from the first dmix enabled process. This can be very confusing.

It would be nice if dmix or dsnoop would change its name after forking.

Well, changing the process name in run time is very tricky on Linux. In other words: no proper way.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#2 lore raw
Quoted 2 lines · Takashi Iwai

Well, changing the process name in run time is very tricky on Linux. In other words: no proper way.

Are you sure? I thought there was a syscall for it.

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#3 lore raw

At Sun, 02 Oct 2005 00:13:56 +0100,

Quoted 6 lines · Mike Hearn
Quoted 2 lines · Takashi Iwai

Well, changing the process name in run time is very tricky on Linux. In other words: no proper way.

Are you sure? I thought there was a syscall for it.

Then I'd be happy to change the code. Could you give a pointer?

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#4 lore raw

Hi David,

Long time no see! If you're ever in England again make sure to drop me a line.

Anyway, I remember you showed me a syscall to change the process name - do you have a function that could be included in ALSA so the forked dmix process can be more obvious?

thanks -mike

Quoted 11 lines · Takashi Iwai

At Sun, 02 Oct 2005 00:13:56 +0100,

Quoted 7 lines · Mike Hearn
Quoted 4 lines · Takashi Iwai

Well, changing the process name in run time is very tricky on Linux. In other words: no proper way.

Quoted 11 lines
Quoted 3 lines

Are you sure? I thought there was a syscall for it.

Then I'd be happy to change the code. Could you give a pointer?

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#5 lore raw
In reply to Takashi Iwai

Actually, I found it - it's SYS_prctl with PR_SET_NAME (2.6 kernels only).

Something like this:

static inline int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
int ret;
__asm__ __volatile__ ( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"

                          : "=a" (ret) : "0" (SYS_prctl), "r" (option),
                          "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) );

return SYSCALL_RET(ret);
}

prctl(15 /* PR_SET_NAME */, (unsigned long)"dmix", 0, 0, 0);

thanks -mike

Quoted 11 lines · Takashi Iwai

At Sun, 02 Oct 2005 00:13:56 +0100,

Quoted 7 lines · Mike Hearn
Quoted 4 lines · Takashi Iwai

Well, changing the process name in run time is very tricky on Linux. In other words: no proper way.

Quoted 11 lines
Quoted 3 lines

Are you sure? I thought there was a syscall for it.

Then I'd be happy to change the code. Could you give a pointer?

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#6 lore raw

At Tue, 04 Oct 2005 15:40:04 +0100,

Quoted 15 lines · Mike Hearn

Actually, I found it - it's SYS_prctl with PR_SET_NAME (2.6 kernels only).

Something like this:

static inline int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)

{
    int ret;
    __asm__ __volatile__ ( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
                           : "=a" (ret) : "0" (SYS_prctl), "r" (option),
                           "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) );
    return SYSCALL_RET(ret);
}
Quoted 1 line

prctl(15 /* PR_SET_NAME */, (unsigned long)"dmix", 0, 0, 0);

Great, looks like we have it in sys/prctl.h.
Let's see whether it works...

Thanks,

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#7 lore raw

At Tue, 04 Oct 2005 16:53:37 +0200,

Quoted 18 lines · I wrote:

At Tue, 04 Oct 2005 15:40:04 +0100,

Quoted 15 lines · Mike Hearn

Actually, I found it - it's SYS_prctl with PR_SET_NAME (2.6 kernels only).

Something like this:

static inline int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)

{
    int ret;
    __asm__ __volatile__ ( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
                           : "=a" (ret) : "0" (SYS_prctl), "r" (option),
                           "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) );
    return SYSCALL_RET(ret);
}
Quoted 4 lines
Quoted 1 line

prctl(15 /* PR_SET_NAME */, (unsigned long)"dmix", 0, 0, 0);

Great, looks like we have it in sys/prctl.h.
Let's see whether it works...

It seems not always working. At least, ps shows the old content while pstree shows the new name. Possibly because /proc entry doesn't change.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#8 lore raw
Quoted 5 lines

It seems not always working. At least, ps shows the old content while pstree shows the new name. Possibly because /proc entry doesn't change.

Try changing argv[0] before the exec() call - it's got something to do with that. I don't remember exactly.

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#9 lore raw

At Tue, 04 Oct 2005 19:38:05 +0100,

Quoted 9 lines · Mike Hearn
Quoted 6 lines

It seems not always working. At least, ps shows the old content while pstree shows the new name. Possibly because /proc entry doesn't change.

Try changing argv[0] before the exec() call - it's got something to do with that. I don't remember exactly.

dmix doesn't exec :)
We may overwrite argv[0] string, but its pointer isn't known in the dmix function.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#10 lore raw
Quoted 6 lines · Takashi Iwai

dmix doesn't exec :)
We may overwrite argv[0] string, but its pointer isn't known in the dmix function.

Hmm, IIRC you can get it from the auxiliary array and there is some way to get the address of that, but right now I don't remember what it is.

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl