loki@NAZGUL.PHYSICS.MCGILL.CA (Loki Jorgenson Rm421) (02/12/91)
Before I write my own script, has anyone already knocked together a "killall" script which functions like the IRIX killall for use on machines which have no such convenience? Thanks, __ __ Loki Jorgenson / / \ \ node: loki@Physics.McGill.CA Grad, Systems Manager / ////// \\\\\\ \ BITNET: PY29@MCGILLA Physics, McGill University \ \\\\\\ ////// / fax: (514) 398-8434 Montreal Quebec CANADA \_\ /_/ phone: (514) 398-7027
c60244@ccfiris.aedc (Kenny McDonald) (02/13/91)
In reply to : -------------------------------------------------------------------------------- Before I write my own script, has anyone already knocked together a "killall" script which functions like the IRIX killall for use on machines which have no such convenience? ________________________________________________________________________________ I have a short c-prog that will do it (you may have to modify it for other machines): #include <stdio.h> main(argc, argv) int argc; char *argv[]; { int i, pid, end=0; char *itoa(); char s[50], bs[100], t1[20][25], *a; FILE *fp; if (argc < 2) { printf ("usage: %s jobname\n",argv[0]); exit(); } for (i=2; i<=argc; ++i) { tmpnam(t1[i]); sprintf (s,"ps -fu %d | grep %s > %s\0",getuid(),argv[i-1],t1[i]); system (s); fp = fopen (t1[i],"r"); if ((fgets(s, 9, fp) == NULL)) { printf ("%s no such job running\n",argv[i-1]); end=1; } else { fscanf (fp,"%d",&pid); fgets (s, 34, fp); fscanf (fp,"%s",s); fgets (bs,256,fp); if ((strcmp(s,argv[i-1])) == 0) { printf ("killing %d\n",pid); kill (pid,9); } } if (end == 0) { while ((fgets(s, 9, fp) != NULL)) { fscanf (fp,"%d",&pid); fgets (s, 34, fp); fscanf (fp,"%s",s); fgets (bs,256,fp); if ((strcmp(s,argv[i-1])) == 0) { printf ("killing %d\n",pid); kill (pid,9); } } } fclose (fp); end=0; } for (i=2; i<=argc; ++i) remove(t1[i]); } vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | Kenneth M. McDonald * OAO Corp * Arnold Engineering Development Center | | MS 120 * Arnold AFS, TN 37389-9998 * (615) 454-3413 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNET: OO AA OO @aedc-vax.af.mil:c60244@ccfiris.aedc O O A A O O O O AAAA O O LOCAL: O O A A O O c60244@ccfiris OO A A OO ________________ /