/* Low level interface to ptrace, for GDB when running under Unix.
- Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <stdio.h>
#include "defs.h"
#include "frame.h"
#include "inferior.h"
#include <fcntl.h>
#include <sys/param.h>
-#include <sys/dir.h>
#include <signal.h>
-extern char *strerror(); /* strings corresponding to errno */
+static void
+kill_command PARAMS ((char *, int));
+
+static void
+terminal_ours_1 PARAMS ((int));
extern struct target_ops child_ops;
/* Does GDB have a terminal (on stdin)? */
int gdb_has_a_terminal;
-
+#if !defined(__GO32__)
static TERMINAL sg_inferior;
static TERMINAL sg_ours;
-
+#endif
static int tflags_inferior;
static int tflags_ours;
void
terminal_init_inferior ()
{
+#if !defined(__GO32__)
sg_inferior = sg_ours;
tflags_inferior = tflags_ours;
#ifdef TIOCGPGRP
pgrp_inferior = inferior_pid;
#endif /* TIOCGPGRP */
-
+#endif
terminal_is_ours = 1;
}
void
terminal_inferior ()
{
+#if !defined(__GO32__)
int result;
if (gdb_has_a_terminal && terminal_is_ours && inferior_thisrun_terminal == 0)
sigquit_ours = (void (*) ()) signal (SIGQUIT, SIG_IGN);
#endif /* TIOCGPGRP */
}
+#endif
terminal_is_ours = 0;
}
terminal_ours_1 (output_only)
int output_only;
{
+#if !defined(__GO32__)
int result;
#ifdef TIOCGPGRP
/* Ignore this signal since it will happen when we try to set the pgrp. */
#else /* not HAVE_TERMIO */
sg_ours.sg_flags &= ~RAW & ~CBREAK;
#endif /* not HAVE_TERMIO */
+
+ result = result; /* lint */
+#endif
}
/* ARGSUSED */
printf_filtered ("This GDB does not control a terminal.\n");
return;
}
-
+#if !defined(__GO32__)
#ifdef TIOCGPGRP
printf_filtered ("Inferior's terminal status (currently saved by GDB):\n");
#ifdef TIOCLGET
printf_filtered ("lmode: 0x%x\n", lmode_inferior);
#endif
+#else
+ printf_filtered("This is a DOS machine; there is no terminal state\n");
+#endif
+
}
\f
/* NEW_TTY_PREFORK is called before forking a new child process,
new_tty ()
{
register int tty;
+ void (*osigttou) ();
if (inferior_thisrun_terminal == 0)
return;
-
+#if !defined(__GO32__)
#ifdef TIOCNOTTY
- /* Disconnect the child process from our controlling terminal. */
+ /* Disconnect the child process from our controlling terminal. On some
+ systems (SVR4 for example), this may cause a SIGTTOU, so temporarily
+ ignore SIGTTOU. */
tty = open("/dev/tty", O_RDWR);
if (tty > 0)
{
+ osigttou = (void (*)()) signal(SIGTTOU, SIG_IGN);
ioctl(tty, TIOCNOTTY, 0);
close(tty);
+ (void) signal(SIGTTOU, osigttou);
}
#endif
{ close (2); dup (tty); }
if (tty > 2)
close(tty);
+#endif /* !go32*/o
}
\f
/* Kill the inferior process. Make us have no inferior. */
error ("The program is not being run.");
if (!query ("Kill the inferior process? "))
error ("Not confirmed.");
- target_kill (arg, from_tty);
+ target_kill ();
/* Killing off the inferior can leave us with a core file. If so,
print the state we are left in. */
{
QUIT;
errno = 0;
- value = call_ptrace (3, inferior_pid, i, 0);
- call_ptrace (6, inferior_pid, i, value);
+ value = call_ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) i, 0);
+ call_ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) i, value);
if (errno == 0)
{
printf (" Succeeded with address 0x%x; value 0x%x (%d).\n",
/* Get all the current tty settings (including whether we have a tty at
all!). */
+#if !defined(__GO32__)
tflags_ours = fcntl (0, F_GETFL, 0);
- OOPSY ("fcntl F_GETFL"); /* Should always work */
result = ioctl (0, TIOCGETP, &sg_ours);
if (result == 0) {
} else {
gdb_has_a_terminal = 0;
}
+#else
+ gdb_has_a_terminal = 0;
+#endif
+
terminal_is_ours = 1;
}