Hi,
Not sure if this is the right forum for this question. Would appreciate
if someone could point me to the correct forum, if this isnt.
I was trying the following program and the main thread also seems to
exit when the spawned thread exits. This happens only when I spawn the
program using the xterm -e <cmd> option to execute the program.
#include <pthread.h>
#include <signal.h>
#include <sys/types.h>
#include <linux/unistd.h>
_syscall0(pid_t,gettid)
pid_t gettid(void);
void* func(void* tmp1)
{
printf("func; Process group = %d;\tpid =
%d;\ttid=%d;\tppid=%d\n",getpgrp(),getpid(),gettid(),getppid());
sleep(2);
}
int main()
{
pthread_attr_t attr;
pthread_t thread;
pthread_attr_init(&attr);
pthread_create(&thread,&attr,func,0);
printf("main; Process group = %d;\tpid =
%d;\ttid=%d;\tppid=%d\n",getpgrp(),getpid(),gettid(),getppid());
while(1)
{
printf("Hello World\n");
sleep(1);
}
}
main; Process group = 30100; pid = 30100; tid=30100;
ppid=30098
Hello World
func; Process group = 30100; pid = 30100; tid=30101;
ppid=30098
Hello World
Hello World
Looking at the strace, the main thread seems to be getting a SIGHUP.
30101 _exit(0) = ?
30100 <... rt_sigprocmask resumed> [], 8) = 0
30100 --- SIGHUP (Hangup) @ 0 (0) ---
30098 <... select resumed> ) = 1 (in [4], left {1, 0})
30098 --- SIGCHLD (Child exited) @ 0 (0) ---
I wasn't sure why SIGHUP is being delivered in this case when tid 30101
is not the process group leader?
Regards,
Sampath.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]