[SERVER-9434] Process exit codes should be between 0 and 255 Created: 23/Apr/13  Updated: 14/Jul/22  Resolved: 07/Jul/22

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: Tad Marshall Assignee: Matt Kneiser
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Affects all platforms; most visible as a difference between Windows and UNIX-style OSes


Issue Links:
Depends
Documented
is documented by DOCS-15473 Investigate changes in SERVER-9434: P... Closed
Related
is related to SERVER-5098 mongos process exit codes are haphaza... Closed
Backwards Compatibility: Major Change
Sprint: Execution Team 2022-06-27, Execution Team 2022-07-11
Participants:
Linked BF Score: 70

 Description   

According to the various standards governing Unix-y systems, only the low-order 8 bits of exit codes are returned to parent processes, meaning that parent processes only see exit code values between 0 and 255.

Several MongoDB executables use negative numbers for error exit codes, so _exit(-3) shows up in the shell as exit code 253.

Windows does not follow this convention, so _exit(-3) shows an exit code of -3.

It would enhance cross-platform compatibility and assist documentation if exit codes were restricted to values that will work on all platforms.



 Comments   
Comment by Githook User [ 14/Jul/22 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-9434 fix embedded sdk compile
Branch: master
https://github.com/mongodb/mongo/commit/ec5c58f99766c4919857e73ec2f3d54aeed0b7fd

Comment by Githook User [ 07/Jul/22 ]

Author:

{'name': 'Matt Kneiser', 'email': 'matt.kneiser@mongodb.com', 'username': 'themattman'}

Message: SERVER-9434 Audit and Normalize Process Exit Codes

  • Put all references to ExitCode enumerators under an enum class to namespace
    all the enumerators and avoid polluting the mongo namespace with possible
    naming collisions.
  • Added magic-number exit codes to exit_code.h like 50 & 51
    (LauncherMiddleError & LauncherError respectively).
  • Reserved a range of exit codes to account for FreeBSD's usage of 64-78.
  • Renamed all enums with removal of EXIT_ which could conflict or get confused
    with built-in macros.
  • camelCased all ExitCode enum values.
  • Added the generic - ExitCode::fail - for returning 1 as failure.
  • Added explicit dependency on the exit_code.h header for all files using
    ExitCode's.
  • Removed all references to implementation-defined exit codes like EXIT_FAILURE
    and EXIT_SUCCESS.
  • Narrowed return values of the shell's undocumented quit() argument to portable
    values within 0-255, 0/ExitCode::clean otherwise.
  • Deprecated 8 unused ExitCode's
  • java
  • oomMalloc
  • oomRealloc
  • fs
  • clockSkew
  • windowsServiceStop
  • possibleCorruption
  • test
  • Wrapped the 2 Windows-only ExitCode's in #ifdef's
  • ntServiceError
  • windowsServiceStop
    Branch: master
    https://github.com/mongodb/mongo/commit/c44db4ac9d0c4c368835dac9f2fbd5869d885f17
Comment by Githook User [ 07/Jul/22 ]

Author:

{'name': 'Matt Kneiser', 'email': 'matt.kneiser@mongodb.com', 'username': 'themattman'}

Message: SERVER-9434 Audit and Normalize Process Exit Codes

Propagates new `ExitCode` convention to the Enterprise module
and replaces negative return codes
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/148c46aa88ab278539ec34ee48636491d3a312db

Comment by Eliot Horowitz (Inactive) [ 23/Apr/13 ]

should make it such that the *nix return codes do not change

Generated at Thu Feb 08 03:20:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.