aboutsummaryrefslogtreecommitdiffstats
path: root/builtins/suspend.def
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>1996-08-26 18:22:31 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:49 +0000
commit726f63884db0132f01745f1fb4465e6621088ccf (patch)
tree6c2f7765a890a97e0e513cb539df43283a8f7c4d /builtins/suspend.def
downloadandroid_external_bash-726f63884db0132f01745f1fb4465e6621088ccf.tar.gz
android_external_bash-726f63884db0132f01745f1fb4465e6621088ccf.tar.bz2
android_external_bash-726f63884db0132f01745f1fb4465e6621088ccf.zip
Imported from ../bash-1.14.7.tar.gz.
Diffstat (limited to 'builtins/suspend.def')
-rw-r--r--builtins/suspend.def86
1 files changed, 86 insertions, 0 deletions
diff --git a/builtins/suspend.def b/builtins/suspend.def
new file mode 100644
index 0000000..48edc20
--- /dev/null
+++ b/builtins/suspend.def
@@ -0,0 +1,86 @@
+This file is suspend.def, from which is created suspend.c.
+It implements the builtin "suspend" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$PRODUCES suspend.c
+
+$BUILTIN suspend
+$DEPENDS_ON JOB_CONTROL
+$FUNCTION suspend_builtin
+$SHORT_DOC suspend [-f]
+Suspend the execution of this shell until it receives a SIGCONT
+signal. The `-f' if specified says not to complain about this
+being a login shell if it is; just suspend anyway.
+$END
+
+#include <sys/types.h>
+#include <signal.h>
+#include "../shell.h"
+#include "../jobs.h"
+
+#if defined (JOB_CONTROL)
+extern int job_control;
+
+static SigHandler *old_cont, *old_tstp;
+
+/* Continue handler. */
+sighandler
+suspend_continue (sig)
+ int sig;
+{
+ set_signal_handler (SIGCONT, old_cont);
+ set_signal_handler (SIGTSTP, old_tstp);
+#if !defined (VOID_SIGHANDLER)
+ return (0);
+#endif /* !VOID_SIGHANDLER */
+}
+
+/* Suspending the shell. If -f is the arg, then do the suspend
+ no matter what. Otherwise, complain if a login shell. */
+int
+suspend_builtin (list)
+ WORD_LIST *list;
+{
+ if (!job_control)
+ {
+ builtin_error ("Cannot suspend a shell without job control");
+ return (EXECUTION_FAILURE);
+ }
+
+ if (list)
+ if (strcmp (list->word->word, "-f") == 0)
+ goto do_suspend;
+
+ no_args (list);
+
+ if (login_shell)
+ {
+ builtin_error ("Can't suspend a login shell");
+ return (EXECUTION_FAILURE);
+ }
+
+do_suspend:
+ old_cont = (SigHandler *)set_signal_handler (SIGCONT, suspend_continue);
+ old_tstp = (SigHandler *)set_signal_handler (SIGTSTP, SIG_DFL);
+ killpg (shell_pgrp, SIGTSTP);
+ return (EXECUTION_SUCCESS);
+}
+
+#endif /* JOB_CONTROL */