Title: | Alpha Developer Support |
Notice: | [email protected], 800-332-4786 |
Moderator: | HYDRA::SYSTEM |
Created: | Mon Jun 06 1994 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3722 |
Total number of notes: | 11359 |
Company Name : CIM Team - Point 19262 Contact Name : Stefan Felkel Phone : Fax : Email : [email protected] Date/Time in : 7-FEB-1997 10:07:56 Entered by : Nick Hudson SPE center : REO Category : vms OS Version : System H/W : Brief Description of Problem: ----------------------------- From: ESSB::ESSB::MRGATE::"ILO::ESSC::dlennon" 7-FEB-1997 09:05:58.62 To: RDGENG::ASAP,LORDS::SIMON CC: Subj: POINT No.19262, CIM Team From: NAME: ESCTECH@ILO TEL: (822-)6704 ADDR: ILO <dlennon@ESSC@ILO> To: ASAP@RDGENG@MRGATE CC: SIMON@LORDS@MRGATE Hello - POINT Log Number 19262 Company Name CIM Team Engineers name Stefan Felkel Telephone Number Fax Number E-mail Address [email protected] Operating System, Version OpenVMS Platform Alpha Problem Statement Dear technical support team, i have problems porting an application from UNIX to VMS. This application starts an external program like an editor or a shell script in a new terminal as a subprocess in the background. The subprocess should inherit the environment of the calling process. The code looks like that: #include <stdio.h> int main( void ) { system( "xterm -exec vi &" ); } When i say create/term ed FILE.TXT on the command line it does exactly what i want, but if i do a system( "create/term ed FILE.TXT" ) from a c program it does not. A system( "create/term/wait ed FILE.TXT" ) works better but it does not return immediately. So i tried system( "spawn/nowait create/term/wait ed FILE.TXT" ) but that doesn't work at all. After i tried many combinations of spawn and create/term i tried the DECwTermPort routine but i didn't find a solution for my problem. So i hope you can help me. Stefan Felkel ( [email protected] ) CIM-Team Technische Informatik GmbH Neue Gasse 10 89077 Ulm ASAP: A60844 -- [email protected]
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
3166.1 | KZIN::HUDSON | That's what I think | Fri Feb 07 1997 06:09 | 52 | |
From: DEC:.REO.REOVTX::HUDSON "[email protected] - UK Software Partner Engineering 830-4121" 7-FEB-1997 11:09:07.36 To: nm%vbormc::"[email protected]" CC: HUDSON Subj: re:asap q 19262, "system" call to create terminal window Hello Stefan Felkel, The "system()" call as implemented on VMS uses the library function "LIB$SPAWN" to create a subprocess which executes the command. What you want (as you have found) is for the subprocess to carry on running in parallel with the parent, and not to terminate when your main program exits. The way you can do this is by using LIB$SPAWN with a "NOWAIT" flag (this is the same as saying "SPAWN/NOWAIT" at the DCL command line). I have included a sample program below which does this and I believe gives you the effect you want. You can't use "system()" to give you the equivalent of "SPAWN/NOWAIT", because DEC C uses the "NOWAIT" mechanism itself to track when the subprocess has completed, and doesn't provide any way for a user program to affect this behaviour via the "system()" call. There is no way to override this behaviour (it's hard coded into the RTL). Please let me know if this solution is acceptable; if not then perhaps you could provide some more info as to what solution would be more helpful. Regards Nick Hudson Digital Software Partner Engineering ////////////////// sample program ///////////////// #include <stdio.h> #include <descrip.h> // need this for $DESCRIPTOR #include <lib$routines.h> // need this for LIB$SPAWN #include <clidef.h> // need this for CLI$M_... flags $DESCRIPTOR(cmd_string,"create/term/wait ed file.txt"); int main(void) { int stat,flags; flags = CLI$M_NOWAIT; stat = lib$spawn( &cmd_string, // command to spawn 0,0, // input/output - default &flags); // NOWAIT flag printf("stat was %d\n",stat); } | |||||
3166.2 | no complaints, closing this one | KZIN::HUDSON | That's what I think | Thu Feb 20 1997 05:29 | 0 |