	PROGRAM resume
C
C Program to implement the RESUME foreign command to restart a suspended
C process:
C
C+ RESUME
C
C The RESUME (foreign) command is used to restart a suspended process.
C The process may have suspended itself using the SUSPEND foreign command,
C by calling the $SUSPND system service from inside an executing image,
C or by being suspended by some other process.
C
C		RESUME{/IDENTIFICATION=pid} {process-name}
C
C Define via:
C		RESUME :== $RESUME
C
C Any user can RESUME one of his/her subprocesses.
C GROUP privilege is reqiired to RESUME detached processes of users
C with the same group number while WORLD privilege allows any process
C to be RESUME'ed.  Note that the process name can only be used when
C dealing with subprocesses or processes owned by users in the same
C group.
C
C-
C
	IMPLICIT INTEGER*4 (A - Z)
	PARAMETER DCL$_IVKEYW = '00038060'X	!Invalid keyword
C
	CHARACTER*80 command
	CHARACTER*16 qualifier
	INTEGER*4 pid,SYS$RESUME
C
	DATA qualifier/'/IDENTIFICATION'/
C
C Get the command line after the verb (RESUME)
C
	status = LIB$GET_FOREIGN(command,'Process? ',length)
	IF (.NOT.status) CALL LIB$STOP(%VAL(status))
C
C Convert the entire command line to uppercase
C
	status = STR$UPCASE(command,command(1:length))
	IF (.NOT.status) CALL LIB$STOP(%VAL(status))
C
C Find out if the /IDENT... qualifier was used
C
	start = LIB$LOCC('/',command(1:length))
	IF (start.NE.0) THEN
	    endstr = LIB$LOCC('=',command(start:length))
	    IF (endstr.EQ.0) CALL LIB$STOP(%VAL(DCL$_IVKEYW))
C
C Check size and content of string for proper keyword
C
	    size = endstr-start
	    IF (size.LT.3) CALL LIB$STOP(%VAL(DCL$_IVKEYW))
	    IF (command(start:endstr-1).NE.qualifier(1:size))
	1	CALL LIB$STOP(%VAL(DCL$_IVKEYW))
C
C Get process id in hexadecimal
C
	    status = ots$cvt_tz_l(command(endstr+1:length),pid)
	    IF (.NOT.status) CALL LIB$STOP(%VAL(status))
C
C now resume the requested process with the process id
C
	    status = SYS$RESUME(pid,)
	    IF (.NOT.status) CALL LIB$STOP(%VAL(status))
C
	    ELSE
C
C No qualifier, try to get process name from command line
C
	    IF (length.NE.0) THEN
C
C now resume the requested process using the process name
C
		pid = 0
		status = SYS$RESUME(pid,command(1:length))
		IF (.NOT.status) CALL LIB$STOP(%VAL(status))
C
		ENDIF
C
	    ENDIF
C
	END
