From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/OR_USING_C/10.2.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 reference/C/CONTRIB/OR_USING_C/10.2.c (limited to 'reference/C/CONTRIB/OR_USING_C/10.2.c') diff --git a/reference/C/CONTRIB/OR_USING_C/10.2.c b/reference/C/CONTRIB/OR_USING_C/10.2.c new file mode 100644 index 0000000..c9ee9dd --- /dev/null +++ b/reference/C/CONTRIB/OR_USING_C/10.2.c @@ -0,0 +1,37 @@ +#include +#include +#include "10.h" + +stop(j) +JOB *j; +{ + /* + * If the job is already stopped, we don't + * need to do anything. + */ + if (j->status & JSTOPPED) + return; + + /* + * If the job's process group is not that of the + * terminal, then the job is in the background + * and must be sent a stop signal. + */ + if (j->pgrp != TermPgrp) + killpg(j->pgrp, SIGSTOP); + + /* + * Mark the job as stopped. + */ + j->status |= JSTOPPED; + + /* + * If the terminal is not in the shell's process + * group, we need to put it there. + */ + if (TermPgrp != MyPgrp) { + ioctl(1, TIOCSPGRP, &MyPgrp); + TermPgrp = MyPgrp; + } +} + -- cgit v1.2.3-54-g00ecf