Like Tree1Likes
  • 1 Post By Salem

Reciving data from a child program

This is a discussion on Reciving data from a child program within the C Programming forums, part of the General Programming Boards category; Hey guys, I'm in need of spawning a separate program from my original (parent) program, which in itself is not ...

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

    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 - Cprogramming.com )

    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 process...is 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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    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
    otaconBot likes this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 04:36 PM
  2. how to catch child program using signals
    By ashok449 in forum C Programming
    Replies: 2
    Last Post: 03-01-2009, 11:50 PM
  3. How to Close Parent Program using child Program?
    By beon in forum Windows Programming
    Replies: 2
    Last Post: 11-30-2007, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21