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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:50:16+00:00 2026-05-18T12:50:16+00:00

this is a follow up to How to squeeze in additional parameters to a

  • 0

this is a follow up to How to squeeze in additional parameters to a reaper function when a parent is signalled to kill a child (c)?

In my reaper(), I try to obtain the child’s pid the parent is about to finish (non-brutal word here). but wait() does not return the pid of the child; instead, it returns 1. I can’t find a doc for return value of 1 anywhere. Any heads up?

void    reaper(int sig)
{
    int status, killedpid;

    while(killedpid = (/*waitpid(-1, &status, WNOHANG)*/wait(&status)) >= 0)
    {
        printf("reaper %d killed %d\n", getpid(), killedpid);
    }
}

My results:

reaper 5933 killed 1 //actual child pid is 5936

Thank you in advance!

  • 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-18T12:50:17+00:00Added an answer on May 18, 2026 at 12:50 pm

    This is the classic assignment in conditional error – the expression is evaluated as following (because comparison has higher precedence then assignment):

    if ( killedpid = ( wait( &status ) >= 0 )) { ...
    

    The killedpid will get a value of TRUE, which is 1 in C. To get around this use parenthesis and compile with high warning levels like -Wall -pedantic:

    if (( killedpid = wait( ... )) >= 0 ) { ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this follow code in my javascript. I call this function when the
I just follow this DIHQuickStart , try to import data to solr from mysql.
Attempting to follow this Java tutorial . About 63 pages in, you are instructed
This is follow up for my last question about converting string to float I
I try to follow this tutorial, but I can't get it to work: http://weierophinney.net/matthew/archives/246-Using-Action-Helpers-To-Implement-Re-Usable-Widgets.html
I follow this tutorial online exactly but somehow it's giving me errors. Saying there
I follow this rule but some of my colleagues disagree with it and argue
Sorry to follow this topic http://stackoverflow.com/questions/11044825/javascript-run-on-ie-7 I want to use document.GetElementByClassName ON INTERNET EXPLORE
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
If you follow this link to one of the pages on my site and

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.