[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] SV: Redirecting stdio using Fforce/Fdup

> From: Howard Chu [hyc@highlandsun.com]
> Sent: 2007-10-29 13:00:34 CET
> Those functions are pretty much the same as Unix dup/dup2 system calls. You 
> first create a pipe, then Fforce the child's stdout/stderr to write to the 
> pipe. Your parent process then reads the pipe to get all of the child's 
> output. If you also need to feed input to the child, then you'll also need a 
> separate pipe for that, and Fforce it to the child's stdin.

Something like this?

  in = Fpipe()
  out = Fpipe()
  Fforce(STDIN, in)
  Fforce(STDOUT, out)
  Pexec(100,"old_shit.tos", 0, 0)

  Communicate with the child here using the in/out pipes.

  Fclose the pipes and restore stdin and stdout when the child exits. Btw. is this necessary? If I don't close the pipes when the child exits, will stdin/stdout of the next child I Pexec be redirected? I don't intend to run several childs concurrently, but I might need to run several in sequence.

Jo Even