Problem with Zombies

Hi, all.

Working from a DiskOnChip, RTOS 6.1, Pentium machine.

I have a the following script:

#!/bin/sh

#----------------------------------------->
#start random
/ram/bin/random &

if this file doesn’t exist, create some keys

don’t bother checking for the other files

if [ ! -f /etc/ssh/ssh_host_key ]; then
echo “need to generate some keys for sshd”

#create all three types just in case user requires other types
/ram/bin/ssh-keygen -q -t rsa1 -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_key’
/ram/bin/ssh-keygen -q -t rsa -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_rsa_key’
/ram/bin/ssh-keygen -q -t dsa -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_dsa_key’
fi

This is run at system start, from the build file.


Later, from a shell, I slay random. If I now run pidin, I can see
that where random was, there is now a zombie where random once was.
The zombie is never cleaned up (or at least not in the hour the
machine continued to run).

In this particular case, it was possible to work around the problem,
by starting random from the build file instead of from the script.
However, I can see this being a problem in other situations (eg
program A spawns program B, but A dies before B, leaving a zombie).

Can anybody tell me if this is a bug or if I’m doing something wrong?

Thanks in advance,
Kevin Lacquement


He that breaks a thing to find out what it is has left the path of
wisdom – Gandalf the Grey

Kevin Lacquement <klacquement@syscor.com> wrote:

Hi, all.

Working from a DiskOnChip, RTOS 6.1, Pentium machine.

I have a the following script:

#!/bin/sh

#-----------------------------------------
#start random
/ram/bin/random &

if this file doesn’t exist, create some keys

don’t bother checking for the other files

if [ ! -f /etc/ssh/ssh_host_key ]; then
echo “need to generate some keys for sshd”

#create all three types just in case user requires other types
/ram/bin/ssh-keygen -q -t rsa1 -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_key’
/ram/bin/ssh-keygen -q -t rsa -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_rsa_key’
/ram/bin/ssh-keygen -q -t dsa -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_dsa_key’
fi

This is run at system start, from the build file.

Is that the entire contents of the script?

Do any of the ssh-keygen routines not return.

Later, from a shell, I slay random. If I now run pidin, I can see
that where random was, there is now a zombie where random once was.
The zombie is never cleaned up (or at least not in the hour the
machine continued to run).

Usually this means that the parent has not waited for the child to
exit. The shell normally does this when it next gets the chance –
but if the shell is waiting for a non-background program to finish
it won’t do any other work, including handling the deaths of backgrounded
children.

In this particular case, it was possible to work around the problem,
by starting random from the build file instead of from the script.
However, I can see this being a problem in other situations (eg
program A spawns program B, but A dies before B, leaving a zombie).

If program A dies, program B should get re-parented, I think to Proc,
and Proc will automatically wait for the death of any children re-parented
to it, and there should be no zombies in this case.

Can anybody tell me if this is a bug or if I’m doing something wrong?

Make sure the shell script isn’t still hanging around.

-David

QNX Training Services
dagibbs@qnx.com

I have the same problem.

I have a program A which spawns a process B and then exits. When I use sin
and pidin I see that process B is still there. I have tried to slay it but
it is still there.

pidin says that B is in STOPPED mode. How do I get rid of B so it does not
appear in sin/pidin? Is there a function to call from A before it exits to
prevent this behaviour?

Paul.


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9pl1mv$rni$4@nntp.qnx.com

Kevin Lacquement <> klacquement@syscor.com> > wrote:
Hi, all.

Working from a DiskOnChip, RTOS 6.1, Pentium machine.

I have a the following script:

#!/bin/sh

#-----------------------------------------
#start random
/ram/bin/random &

if this file doesn’t exist, create some keys

don’t bother checking for the other files

if [ ! -f /etc/ssh/ssh_host_key ]; then
echo “need to generate some keys for sshd”

#create all three types just in case user requires other types
/ram/bin/ssh-keygen -q -t rsa1 -C ‘’ -N ‘’ -f ‘/etc/ssh/ssh_host_key’
/ram/bin/ssh-keygen -q -t rsa -C ‘’ -N ‘’ -f
‘/etc/ssh/ssh_host_rsa_key’
/ram/bin/ssh-keygen -q -t dsa -C ‘’ -N ‘’ -f
‘/etc/ssh/ssh_host_dsa_key’
fi

This is run at system start, from the build file.

Is that the entire contents of the script?

Do any of the ssh-keygen routines not return.

Later, from a shell, I slay random. If I now run pidin, I can see
that where random was, there is now a zombie where random once was.
The zombie is never cleaned up (or at least not in the hour the
machine continued to run).

Usually this means that the parent has not waited for the child to
exit. The shell normally does this when it next gets the chance –
but if the shell is waiting for a non-background program to finish
it won’t do any other work, including handling the deaths of backgrounded
children.

In this particular case, it was possible to work around the problem,
by starting random from the build file instead of from the script.
However, I can see this being a problem in other situations (eg
program A spawns program B, but A dies before B, leaving a zombie).

If program A dies, program B should get re-parented, I think to Proc,
and Proc will automatically wait for the death of any children re-parented
to it, and there should be no zombies in this case.

Can anybody tell me if this is a bug or if I’m doing something wrong?

Make sure the shell script isn’t still hanging around.

-David

QNX Training Services
dagibbs@qnx.com

According to spawn documentation to prevent child from becoming a zombie
when it terminates, create child process with mode == P_NOWAITO.

“Paul Jones” <paul.jones@bnc.ox.ac.uk> wrote in message
news:9q71qo$1qk$1@inn.qnx.com

I have the same problem.

I have a program A which spawns a process B and then exits. When I use
sin
and pidin I see that process B is still there. I have tried to slay it
but
it is still there.

pidin says that B is in STOPPED mode. How do I get rid of B so it does
not
appear in sin/pidin? Is there a function to call from A before it exits
to
prevent this behaviour?

Paul.


“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:9pl1mv$rni$> 4@nntp.qnx.com> …
Kevin Lacquement <> klacquement@syscor.com> > wrote:
Hi, all.

Working from a DiskOnChip, RTOS 6.1, Pentium machine.

I have a the following script:

#!/bin/sh

#-----------------------------------------
#start random
/ram/bin/random &

if this file doesn’t exist, create some keys

don’t bother checking for the other files

if [ ! -f /etc/ssh/ssh_host_key ]; then
echo “need to generate some keys for sshd”

#create all three types just in case user requires other types
/ram/bin/ssh-keygen -q -t rsa1 -C ‘’ -N ‘’ -f
‘/etc/ssh/ssh_host_key’
/ram/bin/ssh-keygen -q -t rsa -C ‘’ -N ‘’ -f
‘/etc/ssh/ssh_host_rsa_key’
/ram/bin/ssh-keygen -q -t dsa -C ‘’ -N ‘’ -f
‘/etc/ssh/ssh_host_dsa_key’
fi

This is run at system start, from the build file.

Is that the entire contents of the script?

Do any of the ssh-keygen routines not return.

Later, from a shell, I slay random. If I now run pidin, I can see
that where random was, there is now a zombie where random once was.
The zombie is never cleaned up (or at least not in the hour the
machine continued to run).

Usually this means that the parent has not waited for the child to
exit. The shell normally does this when it next gets the chance –
but if the shell is waiting for a non-background program to finish
it won’t do any other work, including handling the deaths of
backgrounded
children.

In this particular case, it was possible to work around the problem,
by starting random from the build file instead of from the script.
However, I can see this being a problem in other situations (eg
program A spawns program B, but A dies before B, leaving a zombie).

If program A dies, program B should get re-parented, I think to Proc,
and Proc will automatically wait for the death of any children
re-parented
to it, and there should be no zombies in this case.

Can anybody tell me if this is a bug or if I’m doing something wrong?

Make sure the shell script isn’t still hanging around.

-David

QNX Training Services
dagibbs@qnx.com