1 This file is suspend.def, from which is created suspend.c.
2 It implements the builtin "suspend" in Bash.
4 Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
6 This file is part of GNU Bash, the Bourne Again SHell.
8 Bash is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License along
19 with Bash; see the file COPYING. If not, write to the Free Software
20 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
25 $DEPENDS_ON JOB_CONTROL
26 $FUNCTION suspend_builtin
27 $SHORT_DOC suspend [-f]
28 Suspend the execution of this shell until it receives a SIGCONT
29 signal. The `-f' if specified says not to complain about this
30 being a login shell if it is; just suspend anyway.
35 #if defined (JOB_CONTROL)
36 #if defined (HAVE_UNISTD_H)
38 # include <sys/types.h>
43 #include "../bashtypes.h"
48 #include "bashgetopt.h"
50 extern int job_control;
52 static SigHandler *old_cont;
54 static SigHandler *old_stop;
57 /* Continue handler. */
59 suspend_continue (sig)
62 set_signal_handler (SIGCONT, old_cont);
64 set_signal_handler (SIGSTOP, old_stop);
69 /* Suspending the shell. If -f is the arg, then do the suspend
70 no matter what. Otherwise, complain if a login shell. */
72 suspend_builtin (list)
77 reset_internal_getopt ();
79 while ((opt = internal_getopt (list, "f")) != -1)
94 builtin_error ("cannot suspend a shell without job control");
95 return (EXECUTION_FAILURE);
104 builtin_error ("cannot suspend a login shell");
105 return (EXECUTION_FAILURE);
109 old_cont = (SigHandler *)set_signal_handler (SIGCONT, suspend_continue);
111 old_stop = (SigHandler *)set_signal_handler (SIGSTOP, SIG_DFL);
113 killpg (shell_pgrp, SIGSTOP);
114 return (EXECUTION_SUCCESS);
117 #endif /* JOB_CONTROL */