diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-25 11:25:40 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-25 11:25:40 +0200 |
commit | ded462b0dea5615ac36e1256caffa5f2c7f5f1b8 (patch) | |
tree | 4c18b037e9441b84759df1504f08ff05956af053 /gcc/ada/terminals.c | |
parent | d1eb8a82b2851aba9cc35cc698be7dbf4f80ec9a (diff) | |
download | gcc-ded462b0dea5615ac36e1256caffa5f2c7f5f1b8.zip gcc-ded462b0dea5615ac36e1256caffa5f2c7f5f1b8.tar.gz gcc-ded462b0dea5615ac36e1256caffa5f2c7f5f1b8.tar.bz2 |
[multiple changes]
2017-04-25 Gary Dismukes <dismukes@adacore.com>
* exp_ch7.adb, einfo.ads, sem_prag.adb: Minor reformatting and typo
correction.
2017-04-25 Yannick Moy <moy@adacore.com>
* sem_res.adb (Resolve_Comparison_Op): Do not
attempt evaluation of relational operations inside assertions.
2017-04-25 Justin Squirek <squirek@adacore.com>
* exp_util.adb (Add_Interface_Invariants):
Restored, code moved back from Build_Invariant_Procedure_Body.
(Add_Parent_Invariants): Restored, code moved back from
Build_Invariant_Procedure_Body.
(Build_Invariant_Procedure_Body):
Remove refactored calls and integrated code from
Add_Parent_Invariants and Add_Interface_Invariants.
2017-04-25 Johannes Kanig <kanig@adacore.com>
* errout.adb (Output_Messages): Adjust computation of total
errors
* erroutc.adb (Error_Msg): In statistics counts, deal
correctly with informational messages that are not warnings.
* errutil.adb (Finalize): adjust computation of total errors.
2017-04-25 Arnaud Charlet <charlet@adacore.com trojanek>
* terminals.c (__gnat_terminate_pid): New.
* g-exptty.ads (Terminate_Process): New. Update comments.
From-SVN: r247157
Diffstat (limited to 'gcc/ada/terminals.c')
-rw-r--r-- | gcc/ada/terminals.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c index 35cd743..9133a3b 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c @@ -90,6 +90,12 @@ __gnat_terminate_process (void *desc ATTRIBUTE_UNUSED) } int +__gnat_terminate_pid (int pid ATTRIBUTE_UNUSED) +{ + return -1; +} + +int __gnat_tty_fd (void* t ATTRIBUTE_UNUSED) { return -1; @@ -962,6 +968,47 @@ __gnat_terminate_process (struct TTY_Process* p) return 0; } +typedef struct { + DWORD dwProcessId; + HANDLE hwnd; +} pid_struct; + +static BOOL CALLBACK +find_process_handle (HWND hwnd, pid_struct * ps) +{ + DWORD thread_id; + DWORD process_id; + + thread_id = GetWindowThreadProcessId (hwnd, &process_id); + if (process_id == ps->dwProcessId) + { + ps->hwnd = hwnd; + return FALSE; + } + /* keep looking */ + return TRUE; +} + +int +__gnat_terminate_pid (int pid) +{ + pid_struct ps; + + ps.dwProcessId = pid; + ps.hwnd = 0; + EnumWindows ((WNDENUMPROC) find_process_handle, (LPARAM) &ps); + + if (ps.hwnd) + { + if (!TerminateProcess (ps.hwnd, 1)) + return -1; + else + return 0; + } + + return -1; +} + /* wait for process pid to terminate and return the process status. This implementation is different from the adaint.c one for Windows as it uses the Win32 API instead of the C one. */ @@ -1500,6 +1547,17 @@ int __gnat_terminate_process (pty_desc *desc) return kill (desc->child_pid, SIGKILL); } +/* __gnat_terminate_pid - kill a process + * + * PARAMETERS + * pid unix process id + */ +int +__gnat_terminate_pid (int pid) +{ + return kill (pid, SIGKILL); +} + /* __gnat_tty_waitpid - wait for the child process to die * * PARAMETERS |