home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1696 / killit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  944 b   |  26 lines

  1. static char rcsid[] = "@(#)$Id: killit.c,v 2.0  07/18/90  jbc $";
  2. /***************************************************************************/
  3. /* Copyright (c) 1990  James B. Cummings, Jr.                              */
  4. /*                                                                         */
  5. /*  This program is offered in the Public Domain and is freely available   */
  6. /*    as long as this notice is kept intact with each module.              */
  7. /***************************************************************************/
  8. #include "header.h"
  9.  
  10. killit(pid)
  11. int pid;
  12. {
  13.     kill(pid, SIGHUP);        /* first send "hangup" signal */
  14.     sleep(KWAIT);
  15.  
  16.     if (!kill(pid,0)) {        /* SIGHUP might be ignored   */
  17.         kill(pid, SIGKILL);    /* should do the trick       */
  18.         sleep(KWAIT);
  19.         if (!kill(pid,0))
  20.             return(0);    /* failure refuse to die     */
  21.         else
  22.             return(1);    /* successful kill         */
  23.     } else
  24.         return(1);        /* successful kill with SIGHUP */
  25. }
  26.