UDCSTAFF@UDCVAX.BITNET (09/11/87)
I have been using VAX C version 2.3 to write a program designed to be run as a detached process. It runs fine, but VAX C insists on opening SYS$OUTPUT and SYS$ERROR even though the program does not do any output. There are no Output functions used in the program and when I run it /detached it creates files called SYS$OUTPUT. and SYS$ERROR. Is there a way around this? Is main() doing this? I can close the files with fclose(stdout) and fclose(stderr) but that still leaves me with useless files in my directory. So it seems that stdout and stderr are opened by default (which makes sense for interactive processes, but I need to find a way to prevent them from being opened. Any suggestions...????
carl@CITHEX.CALTECH.EDU (Carl J Lydick) (09/12/87)
> I have been using VAX C version 2.3 to write a program designed to be run > as a detached process. It runs fine, but VAX C insists on opening > SYS$OUTPUT and SYS$ERROR even though the program does not do any output. > There are no Output functions used in the program and when I run it /detached > it creates files called SYS$OUTPUT. and SYS$ERROR. Is there a way around > this? Is main() doing this? I can close the files with fclose(stdout) and > fclose(stderr) but that still leaves me with useless files in my directory. Well, yes and no. In order to achieve at least partial compatibility with that other operating system (U*IX. to avoid a footnote) the VAX C compiler likes to have the three U*IX standard files open. It does this in the following way: If it sees a routine called "main" as the first routine in a module it compiles, it has "main" call "C$MAIN" before it does anythhing else. C$MAIN takes care of parsing the command line and opening the standard files.; > So it seems that stdout and stderr are opened by default (which makes sense > for interactive processes, but I need to find a way to prevent them from > being opened. As you may have gathered from the above, the way to avoid this unfortunate (in a few cases; one that comes immediately to mind is a print symbiont) state of affairs, just don't have a "main" routine. Bear in mind that this also means you've got to parse the command line yourself.
moore@UTKCS2.CS.UTK.EDU (Keith Moore) (09/13/87)
In his message of 11 Sep 87, <UDCSTAFF@UDCVAX.BITNET> writes: >I have been using VAX C version 2.3 to write a program designed to be run >as a detached process. It runs fine, but VAX C insists on opening >SYS$OUTPUT and SYS$ERROR even though the program does not do any output. >There are no Output functions used in the program and when I run it /detached >it creates files called SYS$OUTPUT. and SYS$ERROR. Is there a way around >this? Is main() doing this? I can close the files with fclose(stdout) and >fclose(stderr) but that still leaves me with useless files in my directory. ...to which Carl J. Lydick <CARL@CITHEX.CALTECH.EDU> responds: > If it sees a routine called "main" as the first routine in a module >it compiles, it has "main" call "C$MAIN" before it does anythhing else. >C$MAIN takes care of parsing the command line and opening the standard files.; [...] >As you may have gathered from the above, the way to avoid this unfortunate >(in a few cases; one that comes immediately to mind is a print symbiont) >state of affairs, just don't have a "main" routine. Bear in mind that this >also means you've got to parse the command line yourself. Also bear in mind that several of the C run time library routines will not work as expected unless C$$MAIN has been called. Whenever I write a VAX/VMS C program that doesn't run in the normal environment, I don't define the main() function, and I make sure that NO routines from the C run time library are linked in. Instead, I substitute routines I have written myself or calls to System Services, RMS, etc. On the other hand, perhaps there is an easier solution to your problem. Have you tried run/detached/output=nla0:/error=nla0: ? Keith Moore UT Computer Science Dept. Internet: moore@utkcs2.cs.utk.edu 107 Ayres Hall, UT Campus CSnet: moore@tennessee Knoxville Tennessee BITNET: moore@utkcs1
jmprice@hou2d.UUCP (J.PRICE) (09/14/87)
In article <870912025526.02e@CitHex.Caltech.Edu>, carl@CITHEX.CALTECH.EDU (Carl J Lydick) writes: > >> I have been using VAX C version 2.3 to write a program designed to be run >> as a detached process. It runs fine, but VAX C insists on opening >> SYS$OUTPUT and SYS$ERROR even though the program does not do any output. >> There are no Output functions used in the program and when I run it /detached >> it creates files called SYS$OUTPUT. and SYS$ERROR. Is there a way around >> this? Is main() doing this? I can close the files with fclose(stdout) and >> fclose(stderr) but that still leaves me with useless files in my directory. > If you don't have some problem related to too many files open, why don't you just assign SYS$OUTPUT and SYS$ERROR to the NULL device. John Price
bengtb@erix.UUCP (Bengt Baeverman) (09/14/87)
In article <8709120102.AA10824@ucbvax.Berkeley.EDU> UDCSTAFF@UDCVAX.BITNET writes: >I have been using VAX C version 2.3 to write a program designed to be run >as a detached process. It runs fine, but VAX C insists on opening >SYS$OUTPUT and SYS$ERROR even though the program does not do any output. >There are no Output functions used in the program and when I run it /detached >it creates files called SYS$OUTPUT. and SYS$ERROR. Is there a way around >this? If you are not interested in the output written to SYS$OUTPUT or SYS$ERROR in a detached process it's easy; just start the process with the /OUTPUT=NLA0: /ERROR=NLA0: qualifiers. They will make the output goto to the null device. But normally you would want the output written to SYS$ERROR. Thus a better way to handle this would be to delete the generated file SYS$ERROR only if it larger than zero block. This file will contain the error messages written when (not if, but when) an error occurs in your program. Bengt Baverman bengtb@erix.se