[Coco] (Nitr)OS-9 and path numbers in MWC

Jeff Teunissen deek at d2dc.net
Mon Dec 4 12:46:44 EST 2006


Jeff Teunissen wrote:
> A question for the OS-9 guys. :) I'm modifying the Vu program to be able to
> use stdin as the input file (a la "less" in *nix), and I was wondering if I
> could do the following [pseudocode] like I would in *nix:
> 
> infile = dup (0);	/* stdin */
> close (0);		/* close stdin */
> ignored = dup (1);	/* fd 0 now a duplicate of 1 (stdout) */
> 
> and then read from the infile just like "Vu" while taking user input from the
> new fd 0.

update: yes, this works just fine, and perfectly for RBF redirects (i.e. OS9:
less - < file). Just need some code for checking whether stdin is a pipe, and
if so slurping it into a mktemp() file (checking for /R, /R0, /H0, and /DD in
that order and testing for a TEMP directory at each point) and trapping
interrupt to delete the temp file -- either that or hoping you don't run out
of memory reading it until you get EOF.

-- 
| Jeff Teunissen -=- Pres., Dusk To Dawn Computing -=- deek at d2dc.net
| GPG: 1024D/9840105A 7102 808A 7733 C2F3 097B 161B 9222 DAB8 9840 105A
| Core developer, The QuakeForge Project     http://www.quakeforge.net/
| Specializing in Debian GNU/Linux           http://www.d2dc.net/~deek/



More information about the Coco mailing list