Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005

    can a child process return a value to a parent process ??


    in case i fork a process and i want that process to return a value that should be printed in parent that possible without sharing memory or without using vfork() ????

    is it possible to do it as we do it while using functions in C that return values ??


  2. #2
    from the waitpid() man page
      WIFEXITED(stat_val)      Evaluates to a non-zero value if status
                                        was returned for a child process that
                                        terminated normally.
      WEXITSTATUS(stat_val)    If the value of WIFEXITED(stat_val) is
                                        non-zero, this macro evaluates to the
                                        low-order 8 bits of the status argument
                                        that the child process passed to _exit()
                                        or exit(), or the value the child
                                        process returned from main().
    In other words, you can get the exit() status from the child process using waitpid().

    You need to read all of the man page because there are some other considerations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts