shell file descriptor programming (was: Unlinked temp files)

452is-Kim opus at ihlpe.ATT.COM
Thu May 4 02:25:56 AEST 1989


In article <296 at tree.UUCP>, stever at tree.UUCP (Steve Rudek) writes:
: In article <10944 at bloom-beacon.MIT.EDU>, scs at adam.pika.mit.edu (Steve Summit) writes:
: : 	extern long int atol();
: : 	main(argc, argv) int argc; char *argv[];
: : 	{lseek(atoi(argv[1]), atol(argv[2]), atoi(argv[3]);}
: 
: Neither works under the ksh (Microport System V/AT 2.4) though both work
: under the bourne shell (tested with the shell script).  The ksh failure is
: absolutely silent.
: 
: ----------
: Steve Rudek  {ucbvax!ucdavis!csusac OR ames!pacbell!sactoh0} !tree!stever

I had the same problem when I tried it, but I figured out a solution:

	extern long	lseek();
	main()
	{
		return(lseek(0, 0L, 0));
	}

To use this program to rewind file descriptor 4, for example, you say:

	rewind <&4

I know it's not clean, but it works.  I suppose you could have a shell script
front end that takes an actual argument instead of a redirection.
-- 
						RoBiN G. KiM
						...att!ihlpe!opus



More information about the Comp.unix.wizards mailing list