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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:00:35+00:00 2026-06-19T03:00:35+00:00

At work, we encountered an error when interacting with child processes in an object’s

  • 0

At work, we encountered an error when interacting with child processes in an object’s destructor, and eventually traced it to the $? variable being overwritten during the wait calls. This happens after the call to exit(), so $? additionally meant our program’s return code to the operating system.

Specifically, the perldoc talked about this sort of error:

Inside an END subroutine $? contains the value that is going to be given to exit(). You can modify $? in an END subroutine to change the exit status of your program.

We don’t want that to happen, so we put a local $?=$?; inside of every END block. But now the programs return success to the OS while actually failing in their given task.

I managed to break it down into two sample programs. One that works as intended, and one that fails. This occurs on both v5.8.8 and v5.10.1 for x86_64-linux-thread-multi

Program A: (returns 0 to the operating system)

END{ local $?=$?; }
exit(100);

Program B: (returns 100 to the operating system)

END{ local $?=$?>>8; }
exit(100);

Why does it matter what value was assigned to the local $? in the end block?

  • 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-06-19T03:00:36+00:00Added an answer on June 19, 2026 at 3:00 am

    Looks like a bug in perl. Apparently self assignment of $? in local is broken:

    % perl -wle '$? = 123; print "before: $?"; local $? = $?; print "after: $?"'    
    before: 123
    after: 0
    

    But this version works fine:

    % perl -wle '$? = 123; print "before: $?"; local $? = $? + 0; print "after: $?"'
    before: 123
    after: 123
    

    Pretty bizarre.

    A bug report has been filed.

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

Sidebar

Related Questions

I have encountered this error when trying to push a subrepository to bitbucket: D:\Work\agile.crm.framework>hg
I have encountered a problem twice now whereby a producer thread produces N work
Here is the error message: The installer has encountered an unexpected error installing this
I'm using datamodel validation on my asp.net MVC website and I encountered an error.
I've recently encountered an error trying to host my asp.net site with IIS. I
Okay, I might be going crazy but I've never encountered this error before. This
Convertion fails with the error messages for the projects like the following: VCConvertEngine.dll encountered
I have encountered a strange error. I use Windows 7 x64. Visual Studio 2010
I want to chain methods in Javascript (using Node.js). However, I encountered this error:
I've encountered a strange error when attempting to update a SharePoint 2010 list that

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.