[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Problemer med pipe/fork/execv



Hey

Jeg har kastet mig ud i at lave en lille konsol application der skal
kunne laese en configurations file, og afhaenig af hvad der staar i
den parse STDIN gennem en raekke processer. Jeg har dog desvaere lidt
problemer med at pipe data stroemmen gennem mere end 1 process. Det er
heller ikke lykkes mig at lave et ultra simple program som illustrer
problemet, men da hele programmet kun er ca. 150 liner har jeg tilladt
mig at vedhaefte programmet.

I programmets main sektion er en #ifdef fom man kan vaelge om man vil
koere den fungerende del af koden hvor kun 1 under process er i med i
loekken, eller med 2 under processer.

I det simple eksemple bruger jeg programmet dd som underprocess, og
jeg forventer derfor at alt hvad jeg skriver til stdin kommer tilbage
paa stdout.

Jeg har anvendt strace til at debugge problemet, og her ser det udtil
at jeg ikke faar lukket skrive enden af min pipe til dd programmet.
Dette forstaar jeg ikke da det virker med en process.

Her er hvordan man koere programmet:
bunzip piper.c.bz2
gcc piper.c -o piper
echo "asdfasdf" | ./piper

Foelgende output vil nu komme frem:
/usr/bin/dd 
/usr/bin/dd 
Before select: 0/3
Before write: 0
Before select: 0/3
Before write: 0
Before select: 0/3
Before write: 0
Before select: 0/3
closing an end: 0

Naar tolmodigheden ophoerer kan man trykke ^C for at terminere, og
det vil ogsaa terminere de forkede dd processer:

0+3 records in
0+0 records out
0 bytes (0 B) copied, 55.2315 s, 0.0 kB/s
0+0 records in
0+0 records out
0 bytes (0 B) copied, 55.2279 s, 0.0 kB/s

Her ses det tydeligt at data er kopieret ind i dd, men at den ikke har
modtaget min EOF, og derfor ikke har kopieret dataen ud igen.

Er gaaet lidt i staa med at fejlfinde dette, saa haaber at der er en
som kan give et hint :)

skriv endelig hvis der er noget som skal uddybes.

MVH
Allan W. Nielsen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2009-12-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *