Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Commit7b43f0f
committed
bug#45851 [Console] Fix exit status on uncaught exception with negative code (acoulton)
This PR was merged into the 4.4 branch.Discussion----------[Console] Fix exit status on uncaught exception with negative code| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#45850| License | MIT| Doc PR | N/AAs described in#45850, if an application threw an exception with the `code` property set to a negative number this could in some cases cause the process to appear to exit 'successfully' with a zero exit status. Exiting with any negative number produces potentially unexpected results - the reported exit status will not appear to match the value that was set. This is due to the binary handling / truncation of exit codes.**This PR may theoretically break BC for applications that were intentionally throwing exceptions with negative codes andperforming some action based on that status.** However, given they would have had to implement an algorithm to map e.g. `-10` in PHP to `246` as the actual exit status, it seems unlikely this is a common usage.IMO therefore applications using negative statuses are relying on an undocumented / incorrect implementation, and this is not a formal BC break.I believe it is essentially safe to assume that exceptions with negative codes are e.g. being thrown by lower-level components, and are not intended to set a shell exit status.Coalescing all negative numbers to 1 matches the existing behaviour with other 'invalid' exception codes e.g. empty / zero / non-numeric.This therefore feels the most robust fix and eliminates any potential for confusion.Commits-------e7072aa [Console] Fix exit status on uncaught exception with negative codeFile tree
2 files changed
+20
-1
lines changed- src/Symfony/Component/Console
- Tests
2 files changed
+20
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1175 | 1175 | | |
1176 | 1176 | | |
1177 | 1177 | | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1178 | 1197 | | |
1179 | 1198 | | |
1180 | 1199 | | |
| |||
0 commit comments
Comments
(0)