Re: piping to c



Igna <ignleotta@xxxxxxxxx> wrote:
Hello. I have to write a pipe to joint a GUI in perl and a simulation
program in c. I have read all the docs found in perl.com and now I am
trying to make a test with this simple program. It seems working but it
does not write "bonjour" at the end. Can anybody tell me where my
mistake is? I will be happy for any sample of code for a pipe between c
and perl sent to me too.

Sorry, but you ended up in the wrong place. fork(), dup2() etc.
aren't (standard) C functions but UNIX extensions and for this
reason off-topic here. You will find a much more receptive
audience for your problems in e.g. comp.unix.programmer.

<OT>
You don't even create a pipe using pipe(), so there's no pipe to
write to at all, just an uninitialized array of two integers. And
on top of that you first write to pfd[1] before the dup2() to make
it the standard output of the program. But for more details please
ask in comp.unix.programmer.
</OT>
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.



Relevant Pages

  • Re: read message written to standard output from external program
    ... > I'd like to know how to perform actions based on an external program's> output to standard output while the external program is still running> from the systemcall. ... I'm> trying to minimize it with the genetic algorithm application and> occasionally, it picks parameters that are garbage and makes the> solution go to infinity. ... When you popenthe program, then close'ing the input pipe will not kill the process directly, but the next time the slave process attempts to read input it will see end-of-file. ...
    (comp.soft-sys.matlab)
  • Re: Doubt ls-l|more
    ... Shell will fork one child to execute abve command. ... LS actually has to feed the data into a pipe so that more can use ... with its standard output redirected ...
    (comp.unix.questions)
  • Re: Doubt ls-l|more
    ... The trick is that the shell starts the process, ... with its standard output redirected ... > to a pipe. ... redirect standard output to the pipe ...
    (comp.unix.questions)
  • Re: read message written to standard output from external program
    ... I'm using some c++ code which uses an external ODE solver that writes information to standard output when it's having problems. ... I'm trying to minimize it with the genetic algorithm application and occasionally, it picks parameters that are garbage and makes the solution go to infinity. ... When you popenthe program, then close'ing the input pipe will not kill the process directly, but the next time the slave process attempts to read input it will see end-of-file. ...
    (comp.soft-sys.matlab)
  • Re: Rendezvous between related processes
    ... whose other end isn't connected to the standard output ... And, after the dup2is performed, reading should resume ... > create the pipe, ... Would I read/write directly to the proper ...
    (comp.unix.programmer)