[mod.computers.vax] Shorter alternate to STOP/FORCE

carl@CITHEX.CALTECH.EDU (12/01/86)

I don't know what you did to make your version of a program to force exits
of other processes take thirty-odd blocks (unless you're counting the include
files that DEC supplies in your count), but here's a C program that does
basically the same thing (it doesn't use the CLI routines that yours does,
but DOES let you specify processes by name) that only takes two blocks
(actually, 766 characters):
/*------FORCEX.C--------------FILE_STARTS_HERE-------------------------------*/
#include <descrip.h>
#include <ssdef.h>
#define OK(value) (((stat = (value)) & 7) == 1)
main(nargs, args)
int nargs;
char **args;
{   static char buffer[80] = { '0', 'x', '\0' };
    char temp[80];
    static $DESCRIPTOR(prcnam, buffer);
    static long stat, pid;
    extern long SYS$FORCEX();
    long *pidadr = &pid;
    struct dsc$descriptor *ptr = &prcnam;

    if (nargs == 1)
	strcat(buffer, "0");
    else if (nargs == 2) {
	strcat(buffer, *++args);
  	if (sscanf(buffer, "%x%s", &pid, temp) == 1)
		ptr = 0;
	else {
     		prcnam.dsc$a_pointer = buffer + 2;
		prcnam.dsc$w_length = strlen(prcnam.dsc$a_pointer);
		pidadr = 0;
	}
    } else {
      	puts("USAGE: FORCEX pid\n\tor\n       FORCEX prcnam");
	exit(1);
    }  exit(SYS$FORCEX(pidadr, ptr, 1));
}
/*------FORCEX.C--------------FILE_ENDS_HERE---------------------------------*/

DCOTTLER@rca.com (Dan Cottler) (12/01/86)

>I don't know what you did to make your version of a program to force exits
>of other processes take thirty-odd blocks (unless you're counting the include
>files that DEC supplies in your count), but here's a C program that does
>basically the same thing (it doesn't use the CLI routines that yours does,
>but DOES let you specify processes by name) that only takes two blocks
>(actually, 766 characters):

Dear Mr. Carl%cithex.caltech.edu,

I'm one of the people that asked Mr. Synful%drycas.bitnet for a copy of his
program.  Yes, FORCE is larger than your code.  Both seem to run equally 
well.  But FORCE has something your code doesn't -- A reasonable VMS 
interface and DOCUMENTATION.

Given a choice, I'll take the code from Synful%drycas.bitnet everytime.
His code is much easier to read, much easier to use, and DOCUMENTED.


					- Dan Cottler
					  <dcottler%rca.com@relay.cs.net>
					  or <postmaster@rca.com>
					  RCA Advanced Technology Laboratories
					  Moorestown, NJ