home *** CD-ROM | disk | FTP | other *** search
- /*
- * c-tree Demon to Log-Off Dead User
- *
- * This program is the CONFIDENTIAL and PROPRIETARY property
- * of FairCom(R) Corporation. Any unauthorized use, reproduction or
- * transfer of this program is strictly prohibited.
- *
- * Copyright (c) 1987, 1988, 1989 FairCom Corporation
- * (Subject to limited distribution and
- * restricted disclosure only.)
- * *** ALL RIGHTS RESERVED ***
- *
- * 4006 West Broadway
- * Columbia, MO 65203
- *
- *
- * c-tree(R) Version 4.3
- * Release C
- * February 7, 1989 17:30
- *
- */
-
- #include "ctstdr.h"
- #include "ctoptn.h"
- #include "cterrc.h"
- #include "ctcomm.h"
- #include "ctmssg.h"
- #include <signal.h>
-
- #define MAXASIZ 512
-
- LOCAL MESSAGE msg;
- LOCAL UCOUNT cts_mxaln;
- LOCAL TEXT *apxmsg,*apxdat;
- LOCAL LONG cpid;
- COUNT cts_usrid,uerr_cod,cts_apxsiz,*altseq;
- TEXT ct_buf[CTBUFSIZ];
-
- cleanup(sig)
- int sig;
- {
- COUNT ctrqst();
- TEXT *getmids();
-
- /* set function to special initialization type */
- msg.mfunc = TST_DEDUSR;
- msg.musrn = -1;
-
- /* establish communications with server */
- if ((apxmsg = getmids(cts_apxsiz = MAXASIZ,&msg)) == NULL)
- exit(2);
- apxdat = apxmsg + sizeof(MESSAGE);
-
- /* Try to receive with IPC_NOWAIT just to clear output queue. */
- /* MSG_NOERROR permits a long message to be cleared. */
- msgrcv(getapxid(),apxmsg - LTYPE,cts_apxsiz,cpid,
- IPC_NOWAIT | MSG_NOERROR);
-
- /* send DEAD USER message */
- msg.mfunc = TST_DEDUSR;
- msg.musrn = -1;
- msg.mpntr = cpid;
- ctrqst(apxmsg,&msg);
-
- /* disconnect communications */
- ridmids();
-
- exit(0);
- }
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- /*
- * the command line contains the child pid and optional signals
- * to ignore
- */
-
- /* save child process id */
- cpid = atoi(*++argv);
-
- /* trap HUP or INT or QUIT or TERM to be sure of cleanup */
- signal(SIGHUP,cleanup);
- signal(SIGINT,cleanup);
- signal(SIGQUIT,cleanup);
- signal(SIGTERM,cleanup);
-
- /* optionally cancel signals */
- while (argc-- > 2)
- signal(atoi(*++argv),SIG_IGN);
-
- /* wait for application to terminate */
- wait(NULL);
-
- /* cleanup server if necessary */
- cleanup(0);
- }
-
- /* end of ctdemn.c */
-