aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-06-21 01:11:57 +0100
committerPedro Alves <palves@redhat.com>2016-06-21 01:11:57 +0100
commit49940788ab38b9d58c663cf38855f29c0ebb1b55 (patch)
treeef322e16fd2feb6219aacba550aac37b9b38772f /gdb/python/python.c
parentef274d26b57336b3baa5bb0ae93b49178bc45631 (diff)
downloadbinutils-49940788ab38b9d58c663cf38855f29c0ebb1b55.zip
binutils-49940788ab38b9d58c663cf38855f29c0ebb1b55.tar.gz
binutils-49940788ab38b9d58c663cf38855f29c0ebb1b55.tar.bz2
Always switch fork child to the main UI
The following scenario: - gdb started in normal CLI mode. - separate MI channel created with new-ui - inferior output redirected with the "set inferior-tty" command. - use -exec-run in the MI channel to run the inferior is presently mishandled. When we create the inferior, in fork-child.c, right after vfork, we'll close all the file descriptors in the vfork child, and then dup the tty to file descriptors 0/1/2, create a session, etc. Note that when we close all descriptors, we close the file descriptors behind gdb_stdin/gdb_stdout/gdb_stderr of all secondary UIs... So if anything goes wrong in the child and it calls warning/error, it'll end up writting to the current UI's stdout/stderr streams, which are backed by file descriptors that have since been closed. Because this happens in a vfork region, the corresponding stdin/stdout/stderr in the parent/gdb end up corrupted. The fix is to switch to the main UI right after the vfork, so that gdb_stdin/gdb_stdout/gdb_stderr are correctly mapped to stdin/stdout/stderr (and thus to file descriptors 0/1/2), so this code works as it has always worked. (Technically, we're doing a lot of stuff we shouldn't be doing after a vfork, while we should only be calling async-signal-safe functions.) gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * fork-child.c (fork_inferior): Switch the child to the main UI right after vfork. Save/restore the current UI in the parent. Flush outputs of the main UI instead of the current UI. gdb/testsuite/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * gdb.mi/mi-exec-run.exp: New file.
Diffstat (limited to 'gdb/python/python.c')
0 files changed, 0 insertions, 0 deletions