Thread: Reciving data from a child program

  1. #1
    Registered User
    Join Date
    Aug 2012
    Utrecht, Netherlands

    Reciving data from a child program

    Hey guys,

    I'm in need of spawning a separate program from my original (parent) program, which in itself is not a problem (yes, i checked out the FAQ at FAQ > Run a program from within a program - )

    The simple system() call should suffice (I'm assuming i can parametarize it, as I could from a command line)

    My question is how to get the result data back from the child it possible? I'm basically looking for a 'return' behaviour as in a function call, but it *has* to be done by an external c program.

    My only idea is to make the child process write out the result to a file, and then read it in from the parent, but this fileIO will cripple the speed of my program too much as I need to make hundreds of thousands of those calls...

    any solutions or ideas that I'm not aware of would be appreciated

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you want to get more than a simple status integer (pass or fail) from a child process, with the simplicity of the system() interface, then use
    popen(3): pipe stream to/from process - Linux man page
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parent and child processes program variables
    By tfarmer4 in forum Linux Programming
    Replies: 1
    Last Post: 03-01-2011, 05:36 PM
  2. how to catch child program using signals
    By ashok449 in forum C Programming
    Replies: 2
    Last Post: 03-02-2009, 12:50 AM
  3. How to Close Parent Program using child Program?
    By beon in forum Windows Programming
    Replies: 2
    Last Post: 11-30-2007, 10:24 PM
  4. Data from Child to Parent
    By queen_ayeka in forum C++ Programming
    Replies: 2
    Last Post: 11-01-2007, 04:39 PM
  5. Child watch program need help
    By aaroroge in forum C++ Programming
    Replies: 3
    Last Post: 06-29-2005, 05:42 PM