do you believe X-application will "kill" the CDE and come back to login dialog

1 . Thanks you for reading the letter
2 . I have programe a X-application .Sometimes, I run it from terminal of CDE ,it "kill" the CDE and I meet the login dialog . I debug it . I find that the SIGHUP caused the X-app died .I do not run it from terminal of CDE ,I run it "click button" from panel , it does the same .(the CDE is killed ,come back to login dialog,the X-app receive the SIGHUP)
3 . I wonder when I run X-app from panel ,it does not have a control terminal ,who send it SIGHUP .
I use "ps axj" find the X-app pid = 8874 ppid = 1 pgid = 8700 sessid = 8700 tty = ??
4 . How can I find the session leader use ps command or others
5 .My email is chenhao_no4@yahoo.com.cn

Please read our rules. We don't allow posters to request email responses.

I don't use CDE. But if your program is getting a SIGHUP, there is a way to find out why. You can use sigaction() to install a signal handler. A signal handler installed by sigaction will be called with a pointer to a siginfo structure. The handler can examine the values in the structure to figure out why the signal arrived. Of particular interest are si_pid (sending process ID) and si_uid (sending user ID). The handler could log this info. It could even run "ps" for the pid in question and log that. Then after it exits, you will know exactly why.

And a process can always call getpgrp() to get its own process group id. And it can call getsid() to get the process group id of its session leader.

1 . thanks Perderabo
2 . I do a experiment in Compaq Tru64 Unix.
It (X-applicaton ) "kill" the CDE sometimes .
When the X-Application "kill" the CDE and let me come back to login dialog , it catch all signal SIGHUP (I use sigacton() (its sa_flags = SA_SIGINFO) ). signal SIGHUP , which sent by pid = 0 ,uid = 0 ( in fact it is [kernel idle] )
I add the tcgetsid(STDIN_FILENO) in source code , I find that When I launch the X-applicaion the "session leader" is 2345 (it will change ) , and When I launch the X-application from a menu button , its "session leader" is -1.

I can not understand why the kernel send the SIGHUP . Because :

  1. "the signal is sent to the controlling process(session leader) associated with a controlling terminal if a disconnect is detected bye the terminal inferface" . But When I type the command "ps aux ",I found that the TTY of the X-applicaton is ??? , which indicate that it do not have a controlling terminal device (maybe I am wrong) . Since the X-applicaton does not have a controlling terminal , Why does the kernel sent SIGHUP to it

4 "the signal is also generated if the session leader terminato" . But I use tcgetsid(STDIN_FILENO), I find that the session leader is -1 . Since the session leader is dead (because it is -1) , how can it receive SIGHUP . (sometimes when the session leader is -1 ,the X-applicaton work correctly)

I don't use Compaq. But there is something odd here. Yes, I would agree that if your tty field on "ps" is ??? then you have no controlling terminal. However it may be that you have either a session leader or a process group leader who does have a controlling terminal. I would just take extreme measures to make sure that this is not the case.

1) close all files. If no files are open, then no tty can be open.

2) fork() and let the parent exit. The child will continue to run. The parent might have been a process group leader. But the child cannot be one.

3) setsid() to become a session leader and process group leader.

4) fork() and let the parent exit. At this point the child has no process group leader nor a session group leader. It has no tty's open so it cannot have a controlling tty nor is it associated in any way with a process with a controlling terminal.

5) now run, but never open a tty. If you need to open a tty, fork, let the child it, then let the child exit.

This is more than should really be needed. But I'll bet the rent that it works.