Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:54:40+00:00 2026-05-25T18:54:40+00:00

I made a program using fork() and exec*() . The problem is I can’t

  • 0

I made a program using fork() and exec*(). The problem is I can’t determine success or failure of exec() from parent process because it’s on separated child process. I think kind of signaling can be used to check this state, but I have no idea about this.

  1. What’s the recommended/standard/widely-used way to check this?
  2. And what’s the pitfalls that I have to care about while doing this?

Question Detail Update (Sorry for omission of important detail)

I want to keep both processes are running so I can’t just wait exiting of child process. In other words, I want to be notified about the child process’ exec success or failure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:54:41+00:00Added an answer on May 25, 2026 at 6:54 pm

    Your parent process can use the pid of the child process to detect that it is alive or has exited (and can disambiguate the error code, and died-because-of-signal errors, see waitpid). You can use certain error codes or signals to notify the parent about specific error cases (e.g., in the forked child before the exec), but for a completely generic child, you may not be able to reserve any exit codes or signals (since the parent won’t be able to tell if the exec succeeded and then the child exited with those values).

    Another approach often used is to create a pipe fd pair (see the ‘pipe’ syscall), and pass one end to the child (generally the write end) and the other to the parent. The child can use this to send specific error codes to the parent. And the parent can detect premature termination if the pipe is closed without getting any data. There are some pitfalls: SIGPIPE will be sent to the parent if it reads on a pipe with no active writers, and using up an fd (other than stdin/stdout/stderr) in a child process may confuse some badly-written child processes (though close-on-exec can help fix that).

    In general, all the code I’ve seen to make fork+exec robust is pretty hacky.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a program to solve this problem from the ACM. Matchsticks are ideal
I have made a chat program with using Winsock2.h and the lib file ws2_32.lib.
I made a program that extracts the text from a HTML file. It recurses
I made a program. I also made my own file type, which the program
I have made a program in c and wanted to see, how much memory
I'm trying to automate a program I made with a test suite via a
I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I made a code that translate strings to match each word from the array
I'm trying to write a simple program using WinSnmp in C++. There is very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.