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 531667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:19:29+00:00 2026-05-13T09:19:29+00:00

I get wrong exit code from waitpid and I can’t figure out why. Could

  • 0

I get wrong exit code from waitpid and I can’t figure out why. Could someone give me some ideas?

Here what I do:

  1. I start my child process with open2
  2. then I wait for it to finish with waitpid
  3. get exit code using $?

It always returns with -1 no mater what I return from child process. I check with VS debugger that my program returns an exit code of 0. VS says something like this:

The program '[3256] Test.exe: Native' has exited with code 0 (0x0).

I made sure that pids match.

Any ideas?

  • 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-13T09:19:29+00:00Added an answer on May 13, 2026 at 9:19 am

    I just figured it out. waitpid has 3 stages:

     1. process is running:    waitpid returns 0;   $? is -1
     2. process is exiting:    waitpid returns pid; $? is actual exit code
     3. process doesn't exist: waitpid returns -1;  $? is -1
    

    so when doing something like while(waitpid($pid, WNOHANG) >= 0) exit code must be retrieved once cycle before that.

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

Sidebar

Related Questions

i'm trying to figure out what is wrong in this code. it either doesn't
I'm relatively new to programming so excuse me if I get some terms wrong
I don't get what I'm doing wrong. I'm trying to populate a form from
What's wrong in here, I always get some nasty errors even if the same
Just trying to get my head around what can happen when things go wrong
Not sure what I'm doing wrong but I can't get my JQuery AJAX call
My Get confirm isn't triggering the query? Can anyone see what I'm doing wrong?
What's wrong with this code ? I always get a Object synchronization method was
From the code below I am trying to get the result of the result
I'm trying to run some external executable code from within Python and then make

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.