[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

500.0. "CLI parsing with a detached process" by TSG::KARDON () Mon Jun 15 1987 15:39

    I've got a question for all of you.
    I'm writing a program that will be installed on a system and executed
    via a command verb that is added to the DCLTABLES.
    
    I want to add the following functionality to my program:
    
    		$ VERB /DETACH /OTHER_QUALIFIERS
    
    Currently, people can use the RUN/DETACH command to execute the program
    in a detached process, but they lose the CLI command line parsing.
                                                                               
    
    What I really want is the functionality of:
    
    		$ SPAWN /NOWAIT    VERB /OTHER_QUALIFIERS
    
    with the image executing in a detached process rather than a
    sub-process.  Is there any way (i.e. a SYS$DETACH or a
    SYS$RUN_PROGRAM_DETACHED call) that I can get this functionality? 
                 
    
    -thanks in advance
     Scott Kardon
T.RTitleUserPersonal
Name
DateLines
500.1UFP::MURPHYEuropean or African Swallow?Mon Jun 15 1987 20:595
    The service is called SYS$CREPRC. Run it with INPUT pointing to
    a command file, OUTPUT to a log file, and specify the image
    SYS$SYSTEM:LOGINOUT.EXE. This will create a 'detached' process with
    DCL mapped.
    	-Rick
500.2MARVIN::PALKATue Jun 16 1987 12:5413
    re .1
    I dont think this is sufficient, it does not explain how to pass
    the command line to the new sub process.
    
    You can do it by running a second image which reads up the current
    command line (either by reading it and hacking out the /DETACH or
    by reconstructing it from the results of several calls to DCL)
    and then calls LIB$SPAWN to create the subprocess. This will have
    the effect of doing a SPAWN command.
    
    I dont know of any way to get DCL to do the SPAWN directly.

    Andrew Palka
500.3Can not be a sub-processTSG::KARDONTue Jun 16 1987 13:007
    re .2
    
    I don't want to create a sub-process.  I want a process that will
    stick around when its creator logs out (hence the detached process).
    
    Thanks and keep those ideas flowing,
    -Scott
500.4Command Line is only input from userTSG::KARDONTue Jun 16 1987 13:0810
    I don't know if this will make things a little more obvious.  My
    program does not get any input from its user.  It just hangs out
    in its own (hopefully detached) process and I/O is performed upon
    it by other processes writing to a mailbox that it is monitoring.
    
    All I want to do is to be able to use the CLI to set up its environment
    inside of the detached process.
    
    -thanks again,
     Scott
500.5UFP::MURPHYEuropean or African Swallow?Tue Jun 16 1987 18:2715
    Maybe this will help.
    When your user types: $VERB/DETACH/OTHER_QUALIFIERS
    You open a temporary file. Call it VERB_DETACH.COM.
    (Maybe you could qualify the filename with the user's PID. Whatever.)
    Set up the CLD file so that the /DETACH qualifier sets up an alternate
    syntax entry with one parameter, type=$REST_OF_LINE. Now, when you
    see /DETACH, your routine grabs P1, appends the VERB to it, and
    writes that verb to the temporary file.
    
    Create the detached process running LOGINOUT with the /INPUT pointed
    to your magic temporary file. You can even have the file delete
    itself, as it won't really go away until it is closed.
    
    Does this make it clearer?
    	-Rick
500.6Why even map DCL?FROST::HARRIMAN$GETJPI-yi, $GETJPI-yoWed Jun 17 1987 12:1132
    
    Courtesy of System Service Description (SYS-83)
    
    " A created process will be unable to run an image that calls the
      Run Time Library procedure LIB$DO_COMMAND unless the process was
      created with the IMAGE argument specifying SYS$SYSTEM:LOGINOUT.EXE.
      This is true because SYS$SYSTEM:LOGINOUT.EXE causes a command
      language interpreter to be mapped into the created process, a
      prerequisite for calling LIB$DO_COMMAND."
    
    The significance of this is not that you may or may not be using
    LIB$DO_COMMAND. It is that the CLI does not exist unless you issue
    a $CREPRC using LOGINOUT as the "program". Your SYS$INPUT specification
    would then issue the "appropriate" DCL environmental commands and
    invoke your application (or daemon).
    
    Alternatively the RUN command can create a detached process (under
    a suiably privileged user) and the process characteristics are mostly
    available via it's syntax. This saves you the trouble of needing
    SYS$INPUT defined as something other than NL:. 
    
    I wrote an application (daemon)? which has been running on our cluster
    for over a year which basically receives mailbox messages to snapshot
    activity on the major application which the system runs. The program
    uses a mailbox to communicate with many other processes (about 200-250
    a day). It is invoked via a command procedure and the DCL RUN command.
    The environment by which the monitor runs has no CLI - however the
    process characteristics were customized by the RUN invokation. The
    monitor itself knows and sets up the rest of it's environment by
    calling suitable system services (like $CREMBX and $CRELNM)...
    
    /pjh
500.7If you want DCL, you have to use LOGINOUTERIS::CALLASI have nothing to say, but it's okayWed Jun 17 1987 12:269
    Sigh. If you want to create a detached process that has DCL mapped, the
    way to do it is to do what Rick said in .1 and .5. Call $CREPRC with
    LOGINOUT as its image and some command file. Note that you could easily
    use a mailbox or a pipe for your file, so you don't have to go and play
    file name games (instead, you get to play logical name games :-). If
    you want DCL mapped into your process, you really have to get LOGINOUT
    to do it. 
    
    	Jon
500.8LOGINOUT -- yeahTSG::KARDONThu Jun 18 1987 21:454
    Yeah, it looks like LOGINOUT is the way to go.
    Thanks for your comments.
    
    -Scott
500.9SYS$SNDJBCAKA::PARKCrushed by the wheels of industryWed Jun 24 1987 12:4312
    
    Why not $SNDJBC to create a batch job?  The batch job will have
    DCL mapped (if DCL is specified as the CLI) and you can pass parameters
    through SJC$_PARAMETER1, etc.
    
    The created process will be a detached process.  You will be able
    to parse parameters by compressing the command line in the command
    file that you would submit to the batch queue.
    
    Just a thought.
    
    -x