EOF not detected while reading a pipe

I have a problem with implementing pipe in my own shell (written in
C++). Consider the command ls | sort. The child process executes ls (by
fork and exec), writes the output to a pipe(stdout is associated with
it) and parent process executes sort by reading input from the
pipe(stdin of this process is associated with the read end). The
problem is that the parent reads all available data from pipe but it is
still waiting for further data.i.e EOF is not detected by the parent
process. Since the child process is doing exec, I'm not able to close
the pipe in child...How can I solve the problem???

0
eanbazhagan
8/8/2004 6:30:44 PM
comp.unix.programmer 10730 articles. 0 followers. kokososo56 (349) is leader. Post Follow

2 Replies
1241 Views

Similar Articles

[PageSpeed] 37
eanbazhagan@rediffmail.com wrote:
> I have a problem with implementing pipe in my own shell (written in
> C++). Consider the command ls | sort. The child process executes ls (by
> fork and exec), writes the output to a pipe(stdout is associated with
> it) and parent process executes sort by reading input from the
> pipe(stdin of this process is associated with the read end). The
> problem is that the parent reads all available data from pipe but it is
> still waiting for further data.i.e EOF is not detected by the parent
> process. Since the child process is doing exec, I'm not able to close
> the pipe in child...How can I solve the problem???

Did the writer close the file ?

Perhaps you can show us some code or even the output of strace ?

G
0
Gianni
8/8/2004 2:37:03 PM
eanbazhagan@rediffmail.com wrote:
> I have a problem with implementing pipe in my own shell (written in
> C++). Consider the command ls | sort. The child process executes ls (by
> fork and exec), writes the output to a pipe(stdout is associated with
> it) and parent process executes sort by reading input from the
> pipe(stdin of this process is associated with the read end). The
> problem is that the parent reads all available data from pipe but it is
> still waiting for further data.i.e EOF is not detected by the parent
> process. Since the child process is doing exec, I'm not able to close
> the pipe in child...How can I solve the problem???
> 

It sounds like the write end of the pipe is still being held open by a 
process.  Are you perhaps creating the pipe in the parent and not 
closing the parent's copy of the write end?

-- ced

-- 
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
0
Chuck
8/9/2004 1:48:00 PM
Reply:
Similar Artilces:

Reading in then exporting xls file
So currently im trying to write a file that will read in an xls file (with xlsread), format it a bit in matlab, then export it. Ideally, i'd like to use clipboard('copy', data) to copy the data to the clipboard, but I'd also except exporting it to a txt file. The problem im having though is that when i read in the xls file, matlab makes it into cells. (the xls file has a mix of text and numbers, so i have to import it as a 'raw' data). Both the clipboard and the dlmwrite commands won't write cells though. Could anyone help with this? A sample of my code is below...

eof
I'd like to check, for a filehandle f, that EOF has been reached on it. What's the way to do it? I don't want to try/except on EOF, I want to check, after I read a line, that now we're in the EOF state. In Ruby it's f.eof: In Ruby: >> f = File.open("jopa") => #<File:jopa> >> f.read() => "jopa\n" >> f.eof => true Is there a Python analog? Cheers, Alexy Hi braver, On Wed, 21 Nov 2007 15:17:14 -0800 (PST), braver <deliverable@gmail.com> wrote: >I'd like to check, for a filehandle f, that EOF has been rea...

MSP scene detection
I'm impressed by the scene detector that does so by content. It even has a sensitivity setting. But after you place the files into the timeline, can you go back and start over to join some of the files? I didn't write to ask that question, just to praise the scene detector but it came up while I was writing. : -) ...

read and write
The first parameter to read and write sys calls is int fd. What needs to be put in that parameter? Does a pipe have to be created? I tried to write a string to a file I created with creat and it wrote to stdout instead of the file. Bill On Sat, 01 Aug 2009 13:41:38 -0400, Bill Cunningham wrote: > The first parameter to read and write sys calls is int fd. What needs to > be put in that parameter? Does a pipe have to be created? I tried to > write a string to a file I created with creat and it wrote to stdout > instead of the file. The first argument for read() and write...

detecting whether an element (if any) as the focus
Say you have a webpage where people can email you. On this webpage, there are three form fields - one for your email address, one for the subject, and one for the message content. After the page loads, the focus is placed on the form field for the message content. The problem is... if the webpage is loading slowly, the user might manually give (for example) the subject form field focus and still by typing when the browser automatically moves the focus to the message content form field, effectively splitting their subject line over two form fields. It seems like the best way to counter thi...

Binary File Reading : Metastock
Hi I am having a little trouble trying to read a binary file, I would like to write an ascii to Metastock converter in python but am not having a lot of success. The file formats are http://sf.gds.tuwien.ac.at/00-pdf/m/mstockfl/MetaStock.pdf If any one can point me in the right direction it would be much appreciated. So far I have tried opening file "rb" then trying to use struct and then binascii but I am not too sure what I should be doing and fuction I should be using in binascii ? TIA Jack wrote: > Hi > > I am having a little trouble trying to read a binary f...

DTMF detection through Sound Card
Hi. I have posted two messages, but I can�t get this working. I mean, I' getting the buffer from the sound card, and then I perform the goertze algorithm with this, but the data I get is wrong almost all times. The steps are: Data: Buffer Size: 4096 Kb, N=4096, Sample Rate = 22050, Format: 16 bits 1) When I get the buffer completely filled, I read the buffer (two bytes time) converting the bytes into float types and puting them in a floa array. 2) I perform goertzel in the low and high freq, puting the results in float array 3) Get the two highest values 4) Find if these two highest v...

problem reading multiple worksheets using xlsread
Hi, When trying to read multiple worksheets using xlsread in Matlab 7.5.0.338 (R2007b) for Mac OS X Tiger 10.4.11, I can only read the first three worksheets. On reading sheet4 and onwards, I get the following error message. -- >> [xn xt xr]=xlsread('temp.xls','sheet4','basic'); Warning: XLSREAD has limited import functionality on non-Windows platforms or in basic mode. Refer to HELP XLSREAD for more information. > In xlsread at 201 ??? Error using ==> xlsread>xlsreadold at 519 Specified worksheet was not found. -- Is this a limitation of xlsread...

Detect EOL
I have a bench which reads from a regular text file. Google has not come up with a neat way to detect EOL so I tried to roll my own - snippets follow. I am using ModelSimXE. attempt 1 use std.textio.all -- Declare boolean variable EOL & set to true in declaration -- read new char from file if TxBufEmpty then if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then if EOL then READLINE(TxText, aline) ; char := LF ; else EOL := READ(aline, char) ; -- Compile error. No feasible entries for subprogram "read". end if ; writebyte <= char2slv(char) ; TxByteLoaded := true ; end if ; end...

Reading numbers from Fortran output
Hello All I have a job which requires me to read back output files from a Fortran program into Smalltalk to do further manipulation. Unfortunately Fortran output in scientific (i.e. exponent) notation does not satisfy Smalltalk rules for number formatting, firstly because it usually uses upper case E for the exponent, secondly because it inserts a sign for the exponent whether it is positive or negative. I have added a loose method to String: asFortranNumber ^(self trimBlanks asLowercase copyWithoutAll: '+') asNumber which does the job, but seems rather clunky. ...

A new reader? Welcome to comp.os.linux.setup, read this first if you're new here (FAQ) #259
Netiquette 2006-04#1 New reader? Great! Welcome! Here's how to make best use of this newsgroup and get yourself a slice of the best help available. Now read on ... TESTING YOUR CONNECTION Errm, first a delicate point. Often users accessing a forum like this for the first time don't realize that posts don't show up immediately, certainly not for several minutes, and maybe not for some hours. In the old days, it took as long as the camel bearing the news took! So they tend to post "test" ...

HP 4100 don't detect form A4
Hi: I've a HP Laserjet 4100 printer that, reciently, don't recognize the paperform A4 in tray 2. The printer is good configurated. Can the printer have a paper detector crashed? Thanks. Jes�s Moreno. I had one maybe two cases on lj4100 when the paper size is not detected well. by replacing feeder controller board it is working fine. The feeder controller board can be easy replaced, and if you do not have new one you can check 3 switches on old board are they OK. "Jesus Moreno" <noquiero@nada.com> wrote in message news:et6qmg$usp$1@hefes...

S6 cards detected
With 128MB memory. Presently $50 each. I restored and reassembled sparse pieces of a PC-365. Noticed how, after a while, the PSU will gracefully shut down. I put a BIG fan and it didn't shut down ... I was thinking about repairing and when I put again the power cord ... BOOM ... a Current Mode PWM Controller (UC3845A) exploded ... sigh ... I hate ATX ... the primary is always under voltage ... Oh, I found the replacement, cheap, 1 euro for 5 pieces, but minimal order is 25 :-( What are you saying ? Ah, I must keep spares ;-) ...

OPC reading in Simulink
My problem: I'm reading data to Visual basic 2008. This data comes from a test device; this device sends a load and an extension value. This data is displayed in 2 visual basic textboxes. I want to send the data trough an OPC and link this date to Simulink to get simulation. How can i read the data out of the text boxes in to Simulink? If this is possible how do i configure the input of the component? The data I use will be processed for further calculations so it's not possible to keep the data in VB. regards ...

eye detection algorithm
We are doing a project on "DROWSY DRIVER DETECTION SYSTEM". The problem is regarding the location of eyes in the image. 1.I have an image of a driver's face taken by ccd camera. 2.I want to segment out only eye portion from the image using matlab. 3.To do this I want an algorithm which will detect the eye location in the image Please help me . amol <amol_git@hotmail.com> writes: > We are doing a project on "DROWSY DRIVER DETECTION SYSTEM". > The problem is regarding the location of eyes in the image. > > 1.I have an image of a driver&...

Free Viewer able to read DicomDIR based File-set
Hi everyone, I've been developing a module that given a set of files containing DICOM Instances creates a DicomDIR file and stores all the data into a storagement Media (for instance, a CD). To check it, i'ld like to know if there's any FREE viewer or raw application able to load File-Set structure via the DicomDIR file. I'm not looking for a nice Viewer but for a standard application able to check if what i generate is correct under the DICOM standard. thanks in advanced, Jordi On Sep 27, 5:49 am, jhugu...@gmail.com wrote: > Hi everyone, > > I...

Must Read!!!
New material has been added for the Silktest and WinRunner feature descriptions focusing on the day to day functionality provided by both the tools used for software testing. http://www.it-techexperts.com/Tools/SWFD.asp ...

Named Pipes: WaitNamedPipe
Im testing some things with named pipes at the moment and have a question. My architechture is that im having a A (server for named pipes, in the end it will be 100 of them) - and a couple of clients writing to theese - if the A server isnt up running the B will just save the packets onto the disk instead. My first test from the client was to do a: CreateFile WriteFile CloseHandle That looked like the wrong way to do it, the server had to spawn new threads to handle each connection everytime i closed it. So i started by initializing it: WriteFile and then in th...

Determining EOF using fseek()? #2
Hey, I was wondering if it was possible to determine if you hit 'EOF' using fseek? I'm using fseek to traverse through the file from start to end and capturing the data into a linked list structure. However, my loop doesn't seem to work well - it totally fumbles out actually: while ((a = fseek(fp,0,SEEK_CUR)) == 0){ // code here } Its quite important for me not to disrupt the current position of the cursor since I rely on that to fetch the data from the text file. I thought that the loop would work fine since fseek only returns a non-zero integer on an error but unf...

how to detect window overlap
hi all, i am playing video in a window. i want to pause the video playback when another window is moved on top of this window. are there any window messages that are sent to figure out the following - when the video window is overlapped with anotehr window - when the overlapping window is removed regards ...

Detect the location of eye in the image.
We are doing a project on "DROWSY DRIVER MONITORING SYSTEM. Following are the steps in our project 1.Capture the image of driver's face. 2.Detect the location of eye in the image. I want an algorithm which will locate the eyes in the image captured by ccd camera ...

Detecting ignorable whitespace with Expat
Perhaps I've missed something obvious, but after reading the docs and doing some Google search I can't find how to detect ignorable whitespace with the Expat parser. Could somebody enlighten me? Thanks, -- To reply by e-mail, please remove the extra dot in the given address: m.collado -> mcollado ...

[comp.mail.pine] Welcome! Read this first #2 1321736
Archive-name: mail/agents/pine/faq-resources URL: http://www.zrox.net/Mail/Pine/pip.txt Last-modified: 2002-09-16 Posting-Frequency: Twice monthly Welcome to comp.mail.pine, a newsgroup devoted to discussing the popular Pine mail and news client from the University of Washington. The purpose of this document is to acquaint new readers with the newsgroup, answer some frequently asked questions, and point readers to sources of further information. QUESTIONS 1. The Newsgroup 1.1 What is comp.mail.pine? 1.2 What kind of questions are welcome? 1.3 Are the discussions archived? 1.4...

[FAQ] mini-FAQ V1.68
Subject: CLPB Mini FAQ Archive-name: pascal/borland-minifaq Posting-Frequency: Every week Last-modified: 2006-02-04 Version: 1.68 This document is (in general) posted every week as an aid to new readers of these Newsgroups. It provides background knowledge of the group, answers to the most frequently asked questions, a listing of Pascal resources and netiquette in posting to the groups. Please do take the time to read through this information. Changes to the FAQ, giving a new version number will have a # in the first column for the life of the version. *********************...

EOF calculation
There already exisits a older topic that I started for this but it started = off with a different topic and ended up in EOF. So inorder to spare you guy= s from all the unrelated posts I am starting it again. But trust me this is= not a duplicate as the approach I am discussing here is new So here is what I am trying to do. I needed to calculate how full files are= in a subvol and indicate if they are above, say 80%. I was able to achieve= this using #filnames and a loop but having trouble exiting the loop withou= t hitting a erro. Below is the code ?section EOF1 macro #frame #push fna...