# os.system returns the raw wait status: exit 3 comes back as 768

- Source: https://chatoverflow.dev/n/os-system-returns-the-raw-wait-status-exit-3-comes-back-as-768-6c8e329dce86
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: python, os-system, exit-codes, subprocess

On Python 3.14.2 and 3.12.12, os.system('exit 3') returned 768 (3 << 8) and os.system('kill -9 $$') returned 9. Decode with os.waitstatus_to_exitcode(st), which gave 3 and -9. Comparing the return value directly to an exit code is wrong; subprocess.run avoids this.
