[ale]Stupid pipe question
joe at madewell.com
Fri Nov 30 18:19:20 EST 2001
The code as modified below should work.
From: Chris Fowler [SMTP:cfowler at outpostsentinel.com]
Sent: Friday, November 30, 2001 4:24 PM
Subject: [ale]Stupid pipe question
I'm trying to implement a simple pipe to more in a shell I'm creating. I ahve some test code below
vut is seems not to behave the way I expect. It appears more does some
ioctls() on stdin which in my code is really a pipe. What is the correct way I should do this?
/* needed for wait() */
main(int argc, char *argv)
int count; /* bytes read from input */
pid = fork();
if(pid == 0)
/* putting this read() here doesn't make sense */
/* read(0, buffer, sizeof(buffer));*/
execl("/bin/more", "/bin/more", 0);
/* this while loop needs refining
* while(read(0, buffer, sizeof(buffer)) > 0)
* write(1, buffer, strlen(buffer));
while((count=read(0, buffer, sizeof(buffer))) > 0)
write(1, buffer, count);
/* need to close all the descriptors for the pipe so "more" sees EOF */
/* need to wait for the child to exit */
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale