`sys.exit` from Python no longer exits the GDB process

Gulshan Singh via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CANEZYrcsr4cANwOHSyV3k1n9cPn6XBvYh-heDqy++=gEpVGnLQ@mail.gmail.com>
I'm using GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1)
15.0.50.20240403-git on Ubuntu 24.04, and I'm observing different
behavior with `sys.exit` in Python then when I was using GNU gdb
(Ubuntu 12.1-0ubuntu1~22.04.2) 12.1 on Ubuntu 22.04.

In GDB 12.1, `sys.exit(1)` in Python would exit the GDB process with
an exit code of 1. In GDB 15.0, I'm seeing that there's an exception
message instead, and GDB does not exit:
```
Python Exception <class 'SystemExit'>: 1
Error occurred in Python: 1
```

Is this a bug or intentional behavior? I work on an open source Python
GDB plugin that has some unit tests that get run inside GDB. When an
exception occurs, it's caught and we exit with `sys.exit` so we can
check the return code from our test running scripts. But with the
latest GDB this no longer happens, eventually we run the `quit`
command, and the exit code is zero. If this is intended behavior, is
there any alternative we can use to quit GDB with a non-zero exit code
from Python?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.