home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!EQL.CALTECH.EDU!rankin
- From: rankin@EQL.CALTECH.EDU (Pat Rankin)
- Newsgroups: comp.os.vms
- Subject: Re: LIB$SPAWN
- Message-ID: <920822020019.24e01554@EQL.Caltech.Edu>
- Date: 22 Aug 92 09:01:17 GMT
- Sender: usenet@ucbvax.BERKELEY.EDU
- Organization: The Internet
- Lines: 30
-
- alex khalil <no return address> writes:
- > Would a kind soul explain to me why in the following code, a subprocess
- > is spawned, a sort is started, but the names of the input and output
- > files are not passed. Sort comes back to you and asks for them.
- ...
- DCL_command = "sort data.PCSA data.sort";
- spawn( DCL_command );
- ...
- > void spawn( char *DCL_command )
- > {
- > int status;
- > $DESCRIPTOR( command , DCL_command );
- > if ((( status=LIB$SPAWN( &command )) & 1 ) != 1 ) LIB$STOP( status );
- > }
-
- Because the $DESCRIPTOR macro uses C's sizeof operator to fill in
- the length field. `sizeof DCL_command' is the same as `sizeof(char *)',
- which is always 4 on the VAX. So the command you're actually passing
- to LIB$SPAWN is just "sort" regardless of what the printf() reported.
- Sticking `LIB$PUT_OUTPUT(&command);' into your spawn() routine would
- have shown that.
-
- You need to add
- `command.dsc$w_length = strlen(command.dsc$a_pointer);'
- between the $DESCRIPTOR macro and the call to LIB$SPAWN. Since you're
- not using any of LIB$SPAWN's optional arguments, you might as well use
- `status = system(DCL_command);' and skip the VMS-specific stuff.
-
- Pat Rankin, rankin@eql.caltech.edu
-
-