home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / condor40.zip / CONDOR / src / condor_tools / abort.c next >
C/C++ Source or Header  |  1989-09-02  |  3KB  |  111 lines

  1. /* 
  2. ** Copyright 1986, 1987, 1988, 1989 University of Wisconsin
  3. ** 
  4. ** Permission to use, copy, modify, and distribute this software and its
  5. ** documentation for any purpose and without fee is hereby granted,
  6. ** provided that the above copyright notice appear in all copies and that
  7. ** both that copyright notice and this permission notice appear in
  8. ** supporting documentation, and that the name of the University of
  9. ** Wisconsin not be used in advertising or publicity pertaining to
  10. ** distribution of the software without specific, written prior
  11. ** permission.  The University of Wisconsin makes no representations about
  12. ** the suitability of this software for any purpose.  It is provided "as
  13. ** is" without express or implied warranty.
  14. ** 
  15. ** THE UNIVERSITY OF WISCONSIN DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. ** THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. ** FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN  BE LIABLE FOR
  18. ** ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  21. ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22. ** 
  23. ** Authors:  Allan Bricker and Michael J. Litzkow,
  24. **              University of Wisconsin, Computer Sciences Dept.
  25. ** 
  26. */ 
  27.  
  28.  
  29. #include <stdio.h>
  30. #include <ctype.h>
  31. #include <rpc/types.h>
  32. #include <rpc/xdr.h>
  33. #include <sys/time.h>
  34. #include <sys/resource.h>
  35. #include "debug.h"
  36. #include "except.h"
  37. #include "trace.h"
  38. #include "sched.h"
  39. #include "expr.h"
  40. #include "proc.h"
  41.  
  42. static char *_FileName_ = __FILE__;        /* Used by EXCEPT (see except.h)     */
  43.  
  44. XDR        *xdr_Init();
  45. char    *index();
  46.  
  47. usage( str )
  48. char    *str;
  49. {
  50.     fprintf( stderr, "Usage: %s cluster.proc\n", str );
  51.     exit( 1 );
  52. }
  53.  
  54. main( argc, argv )
  55. int        argc;
  56. char    *argv[];
  57. {
  58.     int            sock = -1;
  59.     int            cmd;
  60.     XDR            xdr, *xdrs = NULL;
  61.     char        hostname[512];
  62.     PROC_ID        job_id;
  63.     char        *cluster_p;
  64.     char        *proc_p;
  65.  
  66.     if( argc != 2 ) {
  67.         usage( argv[0] );
  68.     }
  69.  
  70.     config( argv[0], (CONTEXT *)0 );
  71.  
  72.     cluster_p = argv[1];
  73.     proc_p = index( argv[1], '.' );
  74.     if( proc_p ) {
  75.         proc_p += 1;
  76.     } else {
  77.         usage( argv[0] );
  78.     }
  79.  
  80.     if( !isdigit(cluster_p[0]) || (!isdigit(proc_p[0]) && proc_p[0] != '-') ) {
  81.         EXCEPT( "%s: invalid job id", argv[1] );
  82.     }
  83.  
  84.     job_id.cluster = atoi( cluster_p );
  85.     job_id.proc = atoi( proc_p );
  86.  
  87.  
  88.     if( gethostname(hostname,sizeof(hostname)) < 0 ) {
  89.         EXCEPT( "gethostname failed" );
  90.     }
  91.  
  92.         /* Connect to the specified host */
  93.     if( (sock = do_connect(hostname, "condor_schedd", SCHED_PORT)) < 0 ) {
  94.         dprintf( D_ALWAYS, "Can't connect to schedd on %s\n", hostname );
  95.         exit( 1 );
  96.     }
  97.     xdrs = xdr_Init( &sock, &xdr );
  98.     xdrs->x_op = XDR_ENCODE;
  99.  
  100.     cmd = KILL_FRGN_JOB;
  101.     ASSERT( xdr_int(xdrs, &cmd) );
  102.     ASSERT( xdr_proc_id(xdrs, &job_id) );
  103.     ASSERT( xdrrec_endofrecord(xdrs,TRUE) );
  104.  
  105.     printf( "Sent KILL_FRGN_JOB command to schedd on %s\n", hostname );
  106.  
  107.     exit( 0 );
  108. }
  109.  
  110. SetSyscalls(){}
  111.