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 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
Well lets say I have this follow code in my htaccess file, Options +FollowSymlinks
This is follow-up question after on my question . Folder subfolders imagefolder important.txt index.txt
I follow this answer to post a photo on Facebook. How can I add
I tried to follow this instruction: http://wiki.phonegap.com/w/page/16494774/Getting-started-with-Android-PhoneGap-in-Eclipse I can run the example but when
The simplest way to follow this explanation is a NServiceBus Pub/Sub sample which contains
I have an application that iterates over an array every step and I seem
So I'm trying to page items on my index page using the paginator and
I'm currently writing a simple game. My graphics code runs once per frame (approximately

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.