clone, signal and pids

Luis Irun (lirun@iti.upv.es)
Tue, 09 Feb 1999 20:10:40 +0100


Perhaps this is not the best moment for this question, but I'm by now
developing an extension for the IPC under Linux, and I have been
experimenting whith the clonation. The matter is: I don't agree the
signal behaviour for clones sharing its pid's.

Try this secuence:
A process "P" clones itsef (P'), sharing memory map, files, fs, AND
PID, but not the signal handlers.
After the clonation,
* the process "P" handles the SIGUSR1 signal (signal 10) whith the
function handlerP(...)
* the process "P'" handles the SIGUSR1 signal whith handlerP2(...)

int handlerP( ... ) {
printf("Hi, I'm P\n");
}

int handlerP2( ... ) {
printf("Hi, I'm P'\n");
}

If we see the process list, whe obtain a response similar to this:
$ ps | grep P
PID TTY STAT TIME COMMAND
1262 1 S 0:00 P
1262 1 S 0:00 P
$
sending a signal to a pid 1262 we could expect both processes to
receive it, but...
$ kill -10 1262
Hi, I'm "P'"!
$
Here only one of both processes receives the signal. Which one? When
looking into the kernel code, we can find it: The only process that
receives the signal is the first one the scheduler select for got the
CPU.

My question is:
Ok, Linux allow to clone a process sharing the pid but not the
handler. Then, Is this not the correct behaviour for signals to be sent
to both processes?
I think NO. This wouldn't be consequent whith the semantic for the
signals in unix.
I think the wrong step is allowing the clones to share its pid's.

What is the meaning of share pid's? I don't find any meaning for it.

What do you think about this?

Thanks.

-- 
Luis Irún Briz                              _______  
lirun@iti.upv.es                   |           |          de | 
www.iti.upv.es/~lirun              |           |             |
U.P.V. - [ www.upv.es ]            |nstituto   |ecnológico   |nformática

- 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/