Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Side by Side Diff: gdb/ser-pipe.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/ser-mingw.c ('k') | gdb/serial.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Serial interface for a pipe to a separate program 1 /* Serial interface for a pipe to a separate program
2 Copyright (C) 1999-2001, 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 1999-2001, 2007-2012 Free Software Foundation, Inc.
3 3
4 Contributed by Cygnus Solutions. 4 Contributed by Cygnus Solutions.
5 5
6 This file is part of GDB. 6 This file is part of GDB.
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or 10 the Free Software Foundation; either version 3 of the License, or
(...skipping 12 matching lines...) Expand all
23 #include "ser-base.h" 23 #include "ser-base.h"
24 #include "ser-unix.h" 24 #include "ser-unix.h"
25 25
26 #include "gdb_vfork.h" 26 #include "gdb_vfork.h"
27 27
28 #include <sys/types.h> 28 #include <sys/types.h>
29 #include <sys/socket.h> 29 #include <sys/socket.h>
30 #include <sys/time.h> 30 #include <sys/time.h>
31 #include <fcntl.h> 31 #include <fcntl.h>
32 #include "gdb_string.h" 32 #include "gdb_string.h"
33 #include "gdb_wait.h"
34 33
35 #include <signal.h> 34 #include <signal.h>
36 35
37 static int pipe_open (struct serial *scb, const char *name); 36 static int pipe_open (struct serial *scb, const char *name);
38 static void pipe_close (struct serial *scb); 37 static void pipe_close (struct serial *scb);
39 38
40 extern void _initialize_ser_pipe (void); 39 extern void _initialize_ser_pipe (void);
41 40
42 struct pipe_state 41 struct pipe_state
43 { 42 {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 static void 154 static void
156 pipe_close (struct serial *scb) 155 pipe_close (struct serial *scb)
157 { 156 {
158 struct pipe_state *state = scb->state; 157 struct pipe_state *state = scb->state;
159 158
160 close (scb->fd); 159 close (scb->fd);
161 scb->fd = -1; 160 scb->fd = -1;
162 161
163 if (state != NULL) 162 if (state != NULL)
164 { 163 {
165 int status; 164 int wait_result, status;
166 kill (state->pid, SIGTERM); 165
167 #ifdef HAVE_WAITPID 166 /* Don't kill the task right away, give it a chance to shut down cleanly.
167 » But don't wait forever though. */
168 #define PIPE_CLOSE_TIMEOUT 5
169
168 /* Assume the program will exit after SIGTERM. Might be 170 /* Assume the program will exit after SIGTERM. Might be
169 useful to print any remaining stderr output from 171 useful to print any remaining stderr output from
170 scb->error_fd while waiting. */ 172 scb->error_fd while waiting. */
171 waitpid (state->pid, &status, 0); 173 #define SIGTERM_TIMEOUT INT_MAX
174
175 wait_result = -1;
176 #ifdef HAVE_WAITPID
177 wait_result = wait_to_die_with_timeout (state->pid, &status,
178 » » » » » PIPE_CLOSE_TIMEOUT);
172 #endif 179 #endif
180 if (wait_result == -1)
181 {
182 kill (state->pid, SIGTERM);
183 #ifdef HAVE_WAITPID
184 wait_to_die_with_timeout (state->pid, &status, SIGTERM_TIMEOUT);
185 #endif
186 }
187
173 if (scb->error_fd != -1) 188 if (scb->error_fd != -1)
174 close (scb->error_fd); 189 close (scb->error_fd);
175 scb->error_fd = -1; 190 scb->error_fd = -1;
176 xfree (state); 191 xfree (state);
177 scb->state = NULL; 192 scb->state = NULL;
178 } 193 }
179 } 194 }
180 195
181 int 196 int
182 gdb_pipe (int pdes[2]) 197 gdb_pipe (int pdes[2])
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ops->print_tty_state = ser_base_print_tty_state; 233 ops->print_tty_state = ser_base_print_tty_state;
219 ops->noflush_set_tty_state = ser_base_noflush_set_tty_state; 234 ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
220 ops->setbaudrate = ser_base_setbaudrate; 235 ops->setbaudrate = ser_base_setbaudrate;
221 ops->setstopbits = ser_base_setstopbits; 236 ops->setstopbits = ser_base_setstopbits;
222 ops->drain_output = ser_base_drain_output; 237 ops->drain_output = ser_base_drain_output;
223 ops->async = ser_base_async; 238 ops->async = ser_base_async;
224 ops->read_prim = ser_unix_read_prim; 239 ops->read_prim = ser_unix_read_prim;
225 ops->write_prim = ser_unix_write_prim; 240 ops->write_prim = ser_unix_write_prim;
226 serial_add_interface (ops); 241 serial_add_interface (ops);
227 } 242 }
OLDNEW
« no previous file with comments | « gdb/ser-mingw.c ('k') | gdb/serial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698