This (small) serie: - removes the creation of an extraneous console in the debugger - however, it exhibits an issue in console handling where console is disconnected too late in server, leaving unwanted termios (eg no echo). It modifies the server to disconnect the console when the (unix) process group leader terminates
use case: - apply second patch only - run from shell ./wine winedbg notepad - enter 'quit' in winedbg prompt - back to shell prompt, without echo
A+
---
Eric Pouech (2): server/console: when a Unix process group leader terminates, disconnect the console programs/winedbg: don't allocate a new console for debuggee (that's no longer needed)
programs/winedbg/tgt_active.c | 5 +---- server/console.c | 13 +++++++++++++ server/process.c | 1 + server/process.h | 1 + 4 files changed, 16 insertions(+), 4 deletions(-)
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- server/console.c | 13 +++++++++++++ server/process.c | 1 + server/process.h | 1 + 3 files changed, 15 insertions(+)
diff --git a/server/console.c b/server/console.c index b4ef1d21874..15652cbe0b9 100644 --- a/server/console.c +++ b/server/console.c @@ -1584,3 +1584,16 @@ DECL_HANDLER(get_next_console_request)
release_object( server ); } + +void console_notify_kill( struct process *process ) +{ + struct console_server* server; + if (!process->console) return; + server = process->console->server; + /* If the terminating process is a process group leader (in Unix world), + * and is attached to a pty, we need to disconnect the server (as the controling + * terminal is no longer accessible). + */ + if (server && server->term_fd != -1 && getpgid( process->unix_pid ) == process->unix_pid) + disconnect_console_server( server ); +} diff --git a/server/process.c b/server/process.c index 6d794ba5ead..8538bd89df6 100644 --- a/server/process.c +++ b/server/process.c @@ -972,6 +972,7 @@ static void process_killed( struct process *process )
assert( list_empty( &process->thread_list )); process->end_time = current_time; + console_notify_kill( process ); close_process_desktop( process ); process->winstation = 0; process->desktop = 0; diff --git a/server/process.h b/server/process.h index 22ee8178368..2eb0491261e 100644 --- a/server/process.h +++ b/server/process.h @@ -121,6 +121,7 @@ extern void enum_processes( int (*cb)(struct process*, void*), void *user);
/* console functions */ extern struct thread *console_get_renderer( struct console *console ); +extern void console_notify_kill( struct process *process );
/* process tracing mechanism to use */ #ifdef __APPLE__
Hi Eric,
On 12/9/21 12:16 PM, Eric Pouech wrote:
Signed-off-by: Eric Pouech eric.pouech@gmail.com
server/console.c | 13 +++++++++++++ server/process.c | 1 + server/process.h | 1 + 3 files changed, 15 insertions(+)
diff --git a/server/console.c b/server/console.c index b4ef1d21874..15652cbe0b9 100644 --- a/server/console.c +++ b/server/console.c @@ -1584,3 +1584,16 @@ DECL_HANDLER(get_next_console_request)
release_object( server );
}
+void console_notify_kill( struct process *process ) +{
- struct console_server* server;
- if (!process->console) return;
- server = process->console->server;
- /* If the terminating process is a process group leader (in Unix world),
* and is attached to a pty, we need to disconnect the server (as the controling
* terminal is no longer accessible).
*/
- if (server && server->term_fd != -1 && getpgid( process->unix_pid ) == process->unix_pid)
disconnect_console_server( server );
This check may not be enough in corner cases. The process can attach to a different process' console in Windows sense, but it will still be a process group leader of a group in Unix sense. Also, I think that only input and tcsetattr may be a problem later, output should still work. Do we need do disconnect entire console?
Thanks,
Jacek
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/tgt_active.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 70ad7e8b437..2a48f9648c6 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -600,10 +600,7 @@ static BOOL dbg_start_debuggee(LPSTR cmdLine) startup.wShowWindow = (current.dwFlags & STARTF_USESHOWWINDOW) ? current.wShowWindow : SW_SHOWNORMAL;
- /* FIXME: shouldn't need the CREATE_NEW_CONSOLE, but as usual CUIs need it - * while GUIs don't - */ - flags = DEBUG_PROCESS | CREATE_NEW_CONSOLE; + flags = DEBUG_PROCESS; if (!DBG_IVAR(AlsoDebugProcChild)) flags |= DEBUG_ONLY_THIS_PROCESS;
if (!CreateProcessA(NULL, cmdLine, NULL, NULL, FALSE, flags,