[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

498.0. "Stupid problem trying to use SYS$FORCEX" by FALEK::FALEK (ex-TU58 King) Fri Jun 12 1987 05:16

    Anyone ever use the SYS$FORCEX system service?
    I can't get it to work.
    
    Scenario - I create a subprocess by doing "SPAWN/NOWAIT @LOOP.COM"
    	LOOP.COM is just a DCL command file that sets its priority to
       1 and then counts up to a million.

    I then run the following BASIC program, which prompts for a PID
    and then issues the $FORCEX call. 
    
        
   10 option type=explicit
      external long function sys$forcex
      declare long pid,foo_status
      print "PID ";
      input pid
      foo_status=sys$forcex(pid,,666% by value)
      print "status from $FORCEX was ";foo_status
      end

    If I specify a PID of 0, I (the caller) am forced to exit (correctly)
    If I specify the PID of my subprocess, $FORCEX returns success status
    but my sub-process is not affected. What am I doing wrong?
T.RTitleUserPersonal
Name
DateLines
498.1Not running any programCADSE::MCCARTHYnone availableFri Jun 12 1987 10:0921
    What are you trying to do?  Stop the subprocess completely or just
    prevent it from setting its priority?
    
    Two things may be happening:  (assuming your subprocess recieved
     the FORCEX)
    
      1. You subprocess is trying to exit but because of system overhead
         it is taking too long!
    
      2. Your process was not running anything to force it out of. 
    	 From my experence, when you send a FORCEX signal to a process
         that is doing only DCL commands like "$ I = I + 1", the FORCEX
         has no effect.  Why ?  Do a show process/continuious on your
    	 subprocess (last line shows what program it is running), my guess
	 is that it is not doing executing any program to force it to exit
    	 from.   (I just did it)
    
    Why not do a $DECPRC on it?
    
    mac
    
498.2$forcex <> $delprcFROST::HARRIMANElephant TalkFri Jun 12 1987 13:0417
    
    SYS$FORCEX queues a user-mode exit image AST. DCL does not count as
    an image. Also, any higher-mode AST's must be serviced before the
    user mode AST - for instance a LEF wait needs to be cleared before
    $FORCEX works. I ended up writing a much longer version of your
    program a while ago to get "clean" exits (cleaner than $DELPRC anyway)
    and I found (along with reading the manual) many instances where
    a $FORCEX does essentially nothing but increment the count of user-mode
    AST's pending on a given process. 
    
    Question: does anyone know whether or not you can get a detached
    process to delete itself via $FORCEX? It would seem that since there
    is no CLI in a detached process that issuing a $FORCEX should cause
    it to exit as long as it was in user mode. However, I don't recall
    that detached processes get to user mode. Clarification?
    
    /pjh
498.3I want to force a particular exit statusFALEK::FALEKex-TU58 KingFri Jun 12 1987 15:278
    I was trying to force the sub-process to complete with a particular status.

    I want the parent process (which did a $LIB$SPAWN with wait) to be able
    to tell whether its sub-process was aborted via a command from the
    user interface (which is a separate program). If the user interface
    does a $DELPRC, the parent gets SUCCESS status for the subprocess!
    
    Any ideas?
498.4of the process or the image?FROST::HARRIMANElephant TalkFri Jun 12 1987 20:4425
    
>   I was trying to force the sub-process to complete with a particular status.
>
>   I want the parent process (which did a $LIB$SPAWN with wait) to be able
>   to tell whether its sub-process was aborted via a command from the
>   user interface (which is a separate program). If the user interface
>   does a $DELPRC, the parent gets SUCCESS status for the subprocess!
    
    Ain't that apples and oranges? Subprocess completion will usually
    be success, unless you actually crash the process. 
    A $FORCEX doesn't get you anything there, even if you send something
    like SS$_ABORT at it, it's in the context of the subprocess...
    How is the parent process receiving the status?
    
    It's possible you are seeing LIB$SPAWN completing successfully too...
    
    If I recall, LIB$SPAWN allows you to specify a longword to hold
    the completion status. I assume this is what you are using....
    
    I also recall that if you use $CREPRC instead you can use a mailbox
    to receive the "termination message" of the sub/detached process.
    Have you tried it that way?
    
    /pjh

498.5summaryOPA0::FALEKex-TU58 KingSun Jun 14 1987 03:4313
    I've gotten around my problem of telling whether the sub-process was
    aborted by using a different mechanism. 

    The brief summary of what I found out about $FORCEX is:
    It makes the current image exit (via SYS$EXIT) - however DCL does not
    count as an image, so the user-mode AST stays queued and the NEXT image
    run by the process gets it (assuming user-mode ASTs are enabled).

    Since in my application I have no idea what the sub-process is running,
    I can't use $FORCEX to reliably force an exit with status. So I now
    use $DELPRC and look at an "abort-was-requested" flag that the user
    interface sets.
			thanks - Lou Falek