00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "defs.h"
00022
00023
00024 #include <termios.h>
00025
00026 static void showpginfo(const char *msg)
00027 {
00028 int fd;
00029
00030 printf("%s\n", msg);
00031 printf("\tprocess ID = %ld; parent = %ld\n",
00032 (long)getpid(), (long)getppid());
00033 printf("\tsession ID = %ld; process-group ID = %ld\n",
00034 (long)getsid(0), (long)getpgid(0));
00035 ec_neg1( fd = open("/dev/tty", O_RDWR) )
00036 printf("\tcontrolling terminal's foreground process-group ID = %ld\n",
00037 (long)tcgetpgrp(fd));
00038 #if _XOPEN_VERSION >= 4
00039 printf("\tcontrolling-terminal's session ID = %ld\n",
00040 (long)tcgetsid(fd));
00041 #else
00042 printf("\tcontrolling-terminal's session ID = %ld\n",
00043 (long)getsid(tcgetpgrp(fd)));
00044 #endif
00045 ec_neg1( close(fd) )
00046 return;
00047
00048 EC_CLEANUP_BGN
00049 EC_FLUSH("showpginfo")
00050 EC_CLEANUP_END
00051 }
00052
00053 static void catchsig(int signo)
00054 {
00055 if (signo == SIGCONT)
00056 showpginfo("got SIGCONT");
00057 }
00058
00059 int main(void)
00060 {
00061 struct sigaction act;
00062
00063 memset(&act, 0, sizeof(act));
00064 act.sa_handler = catchsig;
00065 ec_neg1( sigaction(SIGCONT, &act, NULL) )
00066 showpginfo("initial call");
00067 while (true)
00068 sleep(10000);
00069 EC_CLEANUP_BGN
00070 exit(EXIT_FAILURE);
00071 EC_CLEANUP_END
00072 }
00073