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

  • SEARCH
  • Home
  • 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 4614698
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:44:11+00:00 2026-05-22T01:44:11+00:00

I am trying to execute another command line process in parallel with the current

  • 0

I am trying to execute another command line process in parallel with the current process. However, I realize that the command line program sometimes abnormally exits, and that kills my main program as well.

// MAIN PROGRAM
pid = fork();
char *argv[] = { stuff.. };
if (pid == 0) {
    int rc = execv("command line program...", argv);
    }

// DO OTHER STUFF HERE. 

if (pid > 0) {
    waitpid(pid, 0, 0);
}

Is there any way to keep my main program running after the command line program dies abnormally? Thanks!

[UPDATE]:Yes, the main process is writing to a file where the command line is reading from, but it is a normal file, not a pipe. I receive a segfault.

It is extremely hard for me to reproduce the bug, since the child process does not crash very often. But it does happen. Randomly crashing is a known bug in the command line program, which is why I want to keep my main program alive even if the command line dies.

  • 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-22T01:44:12+00:00Added an answer on May 22, 2026 at 1:44 am

    In your real code do you have an else here:

    if (pid == 0) {
        int rc = execv("command line program...", argv);
        // possibly more child stuff
    }
    else {
        // parent stuff
    }
    

    It’s always a good idea to post real code when asking questions here.

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

Sidebar

Related Questions

I'm trying to execute a basic INSERT statement on a MySQL table from a
trying to integrate gmf with xpand. I created a menu, and command using extensions
I'm trying to develop a shell in Linux as an Operating Systems project. One
Im trying to figure out a bug liad on my table today. I haven't
i have a little question about getting access to a method in another controller,
I'm trying to get a little ffmpeg converter-service up and running, made pretty good
I have been trying to find a good definition, and get an understanding, of
For common commands like 'ls', exec() works fine, eg: exec('ls',$output,$retval); var_dump($output,$retval); // $output contains
This is a somewhat long question, but I hope I can express it clearly.

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.