kriso@northstar5.dartmouth.edu (Kris Olander) (06/01/90)
We have been porting our graphic software over to our HP9000-340 and have run into what we think is a bug in the way stdout is handled on HP/UX-6.5. All our applications run under X windows (currently running all R4 binaries and using the corresponding libraries. Our applications fork off a window and then exit. For example, prompt-> scheme (a window opens up and then... prompt-> (the prompt returns because of the exit) Ok, now here comes the problem. When the child tries to print to stdout, the application window disappears. No core file is generated. The same code has been compiled and runs fine on: IBM RTs running AIX 2.2.1 and AOS (BSD 4.3). IBM RS6000 running AIX 3.x ...and other BSD systems. Here is a sample program which produces the same situation: --------------CUT HERE-------------- #include <stdio.h> main() { int fork_ret; printf("before fork\n"); fflush(stdout); fork_ret = fork(); if (fork_ret == -1) { printf("unable to fork a child process"); exit(0); } printf("parent and child before exit\n"); if (fork_ret) /* we are the parent - time to bow out */ { printf("parent exiting\n"); exit(0); } printf("child after fork\n"); sleep(10); /* give parent time to exit */ printf("child done\n"); } -------------CUT HERE------------- Anyone have any clues? The program above sleeps so that we can be sure that the parent exits before the child's printf. # Kris Olander ---- ---- arpa: Kris.Olander@Dartmouth.Edu # # ---------------------------------------------------------- # # System Eng. Project NORTHSTAR # # Thayer School of Eng., Dartmouth College # # Kris Olander ---- ---- arpa: Kris.Olander@Dartmouth.Edu # # ---------------------------------------------------------- # # System Eng. Project NORTHSTAR # # Thayer School of Eng., Dartmouth College #
stroyan@hpfcso.HP.COM (Mike Stroyan) (06/02/90)
> All our applications run under X windows (currently > running all R4 binaries and using the corresponding > libraries. Our applications fork off a window and then > exit. For example, > Ok, now here comes the problem. When the child tries > to print to stdout, the application window disappears. Your child process is receiving a SIGKILL resulting from a SIGTTOU signal to a process with parent process id 1. You have "stty tostop" set on your tty, indicating that background processes should be stopped when they write to the tty. As described in signal(5), the stop action is changed to a SIGKILL for children of init. I suppose the designers felt that an orphan didn't have much hope of being woken up again. You can prevent this behaviour by setting "stty -tostop" or by the equivalent ioctl call on stdout. Or you can ignore the suspend signal by calling "signal(SIGTTOU, SIG_IGN);" after forking the child. Mike Stroyan, stroyan@hpfcla.hp.com
kriso@northstar5 (Kris Olander) (06/08/90)
Bingo! Thanks alot Mike. I wish we could transfer some of our "Software Support Service" $$$$ to your group. You hit first pitch, our support person is still in the batter's box. # Kris Olander ---- ---- arpa: Kris.Olander@Dartmouth.Edu # # ---------------------------------------------------------- # # System Eng. Project NORTHSTAR # # Thayer School of Eng., Dartmouth College #