home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 2.ddi / UNIX / CTDEMN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  2.1 KB  |  101 lines

  1. /*
  2.  *    c-tree Demon to Log-Off Dead User
  3.  *
  4.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  5.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  6.  *    transfer of this program is strictly prohibited.
  7.  *
  8.  *      Copyright (c) 1987, 1988, 1989 FairCom Corporation
  9.  *    (Subject to limited distribution and
  10.  *     restricted disclosure only.)
  11.  *    *** ALL RIGHTS RESERVED ***
  12.  *
  13.  *    4006 West Broadway
  14.  *    Columbia, MO 65203
  15.  *
  16.  *
  17.  *    c-tree(R)    Version 4.3
  18.  *            Release C
  19.  *            February 7, 1989 17:30
  20.  *
  21.  */
  22.  
  23. #include "ctstdr.h"
  24. #include "ctoptn.h"
  25. #include "cterrc.h"
  26. #include "ctcomm.h"
  27. #include "ctmssg.h"
  28. #include <signal.h>
  29.  
  30. #define MAXASIZ    512
  31.  
  32. LOCAL MESSAGE    msg;
  33. LOCAL UCOUNT    cts_mxaln;
  34. LOCAL TEXT     *apxmsg,*apxdat;
  35. LOCAL LONG    cpid;
  36. COUNT        cts_usrid,uerr_cod,cts_apxsiz,*altseq;
  37. TEXT        ct_buf[CTBUFSIZ];
  38.  
  39. cleanup(sig)
  40. int    sig;
  41. {
  42.     COUNT ctrqst();
  43.     TEXT *getmids();
  44.  
  45.     /* set function to special initialization type */
  46.     msg.mfunc = TST_DEDUSR;
  47.     msg.musrn = -1;
  48.  
  49.     /* establish communications with server */
  50.     if ((apxmsg = getmids(cts_apxsiz = MAXASIZ,&msg)) == NULL)
  51.         exit(2);
  52.     apxdat      = apxmsg + sizeof(MESSAGE);
  53.  
  54.     /* Try to receive with IPC_NOWAIT just to clear output queue. */
  55.     /* MSG_NOERROR permits a long message to be cleared.           */
  56.     msgrcv(getapxid(),apxmsg - LTYPE,cts_apxsiz,cpid,
  57.         IPC_NOWAIT | MSG_NOERROR);
  58.  
  59.     /* send DEAD USER message */
  60.     msg.mfunc = TST_DEDUSR;
  61.     msg.musrn = -1;
  62.     msg.mpntr = cpid;
  63.     ctrqst(apxmsg,&msg);
  64.  
  65.     /* disconnect communications */
  66.     ridmids();
  67.  
  68.     exit(0);
  69. }
  70.  
  71. main(argc,argv)
  72. int argc;
  73. char *argv[];
  74. {
  75.     /*
  76.      * the command line contains the child pid and optional signals
  77.      * to ignore
  78.      */
  79.  
  80.     /* save child process id */
  81.     cpid = atoi(*++argv);
  82.  
  83.     /* trap HUP or INT or QUIT or TERM to be sure of cleanup */
  84.     signal(SIGHUP,cleanup);
  85.     signal(SIGINT,cleanup);
  86.     signal(SIGQUIT,cleanup);
  87.     signal(SIGTERM,cleanup);
  88.  
  89.     /* optionally cancel signals */
  90.     while (argc-- > 2)
  91.         signal(atoi(*++argv),SIG_IGN);
  92.  
  93.     /* wait for application to terminate */
  94.     wait(NULL);
  95.  
  96.     /* cleanup server if necessary */
  97.     cleanup(0);
  98. }
  99.  
  100. /* end of ctdemn.c */
  101.