* inftarg.c (child_thread_alive): New function to see if a
[deliverable/binutils-gdb.git] / gdb / inflow.c
index 4ccbd36add1fcdca0b7f194ebdffc9e90da78b42..353c6c4ee3f417c72515397fdb3f257c5ef6ed4c 100644 (file)
@@ -533,8 +533,7 @@ kill_command (arg, from_tty)
      char *arg;
      int from_tty;
 {
-  /* Shouldn't this be target_has_execution?  FIXME.  */
-  if (inferior_pid == 0)
+  if (!target_has_execution)
     error ("The program is not being run.");
   if (!query ("Kill the program being debugged? "))
     error ("Not confirmed.");
@@ -545,7 +544,7 @@ kill_command (arg, from_tty)
   /* Killing off the inferior can leave us with a core file.  If so,
      print the state we are left in.  */
   if (target_has_stack) {
-    printf_filtered ("In %s,\n", current_target->to_longname);
+    printf_filtered ("In %s,\n", target_longname);
     if (selected_frame == NULL)
       fputs_filtered ("No selected stack frame.\n", gdb_stdout);
     else
@@ -578,6 +577,67 @@ clear_sigint_trap()
   signal (SIGINT, osig);
 }
 \f
+#if defined (SIGIO) && defined (FASYNC) && defined (FD_SET) && defined (F_SETOWN)
+static void (*old_sigio) ();
+
+static void
+handle_sigio (signo)
+     int signo;
+{
+  int numfds;
+  fd_set readfds;
+
+  signal (SIGIO, handle_sigio);
+
+  FD_ZERO (&readfds);
+  FD_SET (target_activity_fd, &readfds);
+  numfds = select (target_activity_fd + 1, &readfds, NULL, NULL, NULL);
+  if (numfds >= 0 && FD_ISSET (target_activity_fd, &readfds))
+    {
+      if ((*target_activity_function) ())
+       kill (inferior_pid, SIGINT);
+    }
+}
+
+static int old_fcntl_flags;
+
+void
+set_sigio_trap ()
+{
+  if (target_activity_function)
+    {
+      old_sigio = (void (*) ()) signal (SIGIO, handle_sigio);
+      fcntl (target_activity_fd, F_SETOWN, getpid()); 
+      old_fcntl_flags = fcntl (target_activity_fd, F_GETFL, 0);
+      fcntl (target_activity_fd, F_SETFL, old_fcntl_flags | FASYNC);
+    }
+}
+
+void
+clear_sigio_trap ()
+{
+  if (target_activity_function)
+    {
+      signal (SIGIO, old_sigio);
+      fcntl (target_activity_fd, F_SETFL, old_fcntl_flags);
+    }
+}
+#else /* No SIGIO.  */
+void
+set_sigio_trap ()
+{
+  if (target_activity_function)
+    abort ();
+}
+
+void
+clear_sigio_trap ()
+{
+  if (target_activity_function)
+    abort ();
+}
+#endif /* No SIGIO.  */
+\f
 
 /* This is here because this is where we figure out whether we (probably)
    have job control.  Just using job_control only does part of it because
This page took 0.025071 seconds and 4 git commands to generate.