Article View: alt.msdos.programmer
Article #58Re: printing through spawn
From: Alexander Pruss
Date: Tue, 04 Aug 1992 21:07
Date: Tue, 04 Aug 1992 21:07
45 lines
2260 bytes
2260 bytes
In article <drice.712955251@ponder> drice@ponder.csci.unt.edu (Keith Rice) writes:
>In <1992Aug4.091802.10778@funet.fi> me74955@cs.tut.fi (Elo Marko Juhani) writes:
>
>
>>I'm working with MSC 5.0 compiler and have tried to use the "print"-
>>command through spawn-function. Even huge drawings work fine, but how
>>can I prevent the message "... is currently being printed" from showing
>>up? I've tried to give a parameter ">tmp", or ">" and "tmp" to spawn,
>>but I get the message "parameter format incorrect".
>
>I tried the same thing and used "> nul" at the end of the print command
>and everything worked OK for me.
A little problem in both cases. You have to be sure that PRINT has been
invoked before your program is run. Otherwise, the SPAWNed PRINT will
attempt to go memory resident, and OOPS, we will be in trouble, since
the newly resident PRINT will lock your program forever in memory.
--
ANyway, your problem has two solutions. One is to use the system()
call, which is fine, but it loads COMMAND.COM and might do dangerous
things in low memory situations. The other is to dup some handles.
I think this works, but have not tested:
{
int h1,h2;
h1=open("NUL",O_WRITE);
h2=dup(fileno(stdout));
dup2(h1,fileno(stdout)); /* or h2,h1??? */
spawn(... /* no > NUL, just the normal spawn */ );
dup2(h2,fileno(stdout));
close(h1);
}
However, because of the abovementioned problems, I recommend that you
just copy the file to stdprn yourself (but no spooling then).
--
Alexander Pruss, Dept. of Mathematics, U. of British Columbia, Vancouver,Canada
pruss@math.ubc.ca
Where there is no love, put love, and you will draw out love.
- St. John of the Cross
Technical Details
Message-ID:
<1992Aug4.210742.9644@unixg.ubc.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!gumby!destroyer!ubc-cs!unixg.ubc.ca!prussReferences:
<1992Aug4.091802.10778@funet.fi> <drice.712955251@ponder>Show Full Headers
Complete Article Headers
Newsgroups: alt.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!destroyer!ubc-cs!unixg.ubc.ca!pruss From: pruss@unixg.ubc.ca (Alexander Pruss) Subject: Re: printing through spawn Message-ID: <1992Aug4.210742.9644@unixg.ubc.ca> Sender: news@unixg.ubc.ca (Usenet News Maintenance) Nntp-Posting-Host: unixg.ubc.ca Organization: University of British Columbia, Vancouver, B.C., Canada References: <1992Aug4.091802.10778@funet.fi> <drice.712955251@ponder> Distribution: usa Date: Tue, 4 Aug 1992 21:07:42 GMT Lines: 46