Hi,
We've had a problem reported on MicroBlaze arch and I was wondering if
someone with access to another NOMM Uarch could run the same test, see
if the result is duplicated.
It's a simple test case attached (don't forget to link pthreads library).
Basically we have parent that
1. blocks all signals
2. spawns a thread (SigHandler)
3. vforks()
- child does execve("/bin/ls",NULL)
- parent sleep() loops forever
The SigHandler thread
1. blocks all signals
2. does a sigwait() loop
if SIGCHLD delivered,
_exit()
On regular PC, this runs as expected - as soon as 'ls' completes,
everything shuts down.
However on MicroBlaze / noMMU, the child of the vfork() ('ls') becomes a
Zombie and never exits, thus SIGCHLD never gets raised, and it all hangs.
Reports of behaviour on another noMMU arch would be greatly appreciated.
Is this a noMMU-ism? If so, any simple workarounds ? Otherwise, I'll
have to go digging in arch/microblaze :(
Thanks,
John
/*
* Placeholder PetaLinux user application.
*
* Replace this with your application code
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
void SigHandler(int SigNum);
void* SigHandlerThread(void* args);
int main(int argc, char *argv[])
{
//signal(SIGCHLD, SigHandler);
sigset_t signal_set;
sigemptyset(&signal_set);
sigaddset(&signal_set, SIGCHLD);
pthread_sigmask(SIG_BLOCK, &signal_set, NULL);
pthread_t SignalThread;
pthread_create(&SignalThread, NULL, &SigHandlerThread, NULL);
int pid = vfork();
if (pid < 0)
{
perror("vfork");
return -1;
}
if (pid == 0) // Child
{
if (execvp ("/bin/ls", NULL) < 0)
{
perror("exec");
}
_exit(EXIT_FAILURE);
}
else // Parent
{
while (1)
sleep(1);
}
return 0;
}
void* SigHandlerThread(void* args)
{
sigset_t signal_set;
int sig;
while (1)
{
sigfillset(&signal_set);
sigwait(&signal_set, &sig);
if (sig == SIGCHLD)
SigHandler(sig);
}
}
void SigHandler(int SigNum)
{
if (SigNum == SIGCHLD)
{
printf("Child has finished.\n");
_exit(EXIT_SUCCESS);
}
}
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev