1251877Speter/* $OpenBSD: hack.ioctl.c,v 1.10 2016/01/09 21:54:11 mestre Exp $ */ 2251877Speter 3251877Speter/* 4251877Speter * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, 5251877Speter * Amsterdam 6251877Speter * All rights reserved. 7251877Speter * 8251877Speter * Redistribution and use in source and binary forms, with or without 9251877Speter * modification, are permitted provided that the following conditions are 10251877Speter * met: 11251877Speter * 12251877Speter * - Redistributions of source code must retain the above copyright notice, 13251877Speter * this list of conditions and the following disclaimer. 14251877Speter * 15251877Speter * - Redistributions in binary form must reproduce the above copyright 16251877Speter * notice, this list of conditions and the following disclaimer in the 17251877Speter * documentation and/or other materials provided with the distribution. 18251877Speter * 19253895Speter * - Neither the name of the Stichting Centrum voor Wiskunde en 20251877Speter * Informatica, nor the names of its contributors may be used to endorse or 21251877Speter * promote products derived from this software without specific prior 22251877Speter * written permission. 23251877Speter * 24251877Speter * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 25251877Speter * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26251877Speter * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 27251877Speter * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 28251877Speter * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29253895Speter * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30253895Speter * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31253895Speter * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32253895Speter * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33253895Speter * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34253895Speter * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35253895Speter */ 36251877Speter 37251877Speter/* 38251877Speter * Copyright (c) 1982 Jay Fenlason <hack@gnu.org> 39251877Speter * All rights reserved. 40253895Speter * 41253895Speter * Redistribution and use in source and binary forms, with or without 42251877Speter * modification, are permitted provided that the following conditions 43251877Speter * are met: 44251877Speter * 1. Redistributions of source code must retain the above copyright 45251877Speter * notice, this list of conditions and the following disclaimer. 46251877Speter * 2. Redistributions in binary form must reproduce the above copyright 47251877Speter * notice, this list of conditions and the following disclaimer in the 48251877Speter * documentation and/or other materials provided with the distribution. 49251877Speter * 3. The name of the author may not be used to endorse or promote products 50251877Speter * derived from this software without specific prior written permission. 51251877Speter * 52251877Speter * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 53251877Speter * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 54251877Speter * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 55251877Speter * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 56251877Speter * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 57251877Speter * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 58251877Speter * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 59251877Speter * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 60251877Speter * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 61251877Speter * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62251877Speter */ 63253895Speter 64253895Speter/* This cannot be part of hack.tty.c (as it was earlier) since on some 65251877Speter systems (e.g. MUNIX) the include files <termio.h> and <sgtty.h> 66251877Speter define the same constants, and the C preprocessor complains. */ 67251877Speter#include <stdio.h> 68251877Speter#include <termios.h> 69251877Speter 70251877Speter#include "hack.h" 71251877Speter 72251877Speterstruct termios termios; 73251877Speter 74251877Spetervoid 75251877Spetergetioctls(void) 76251877Speter{ 77251877Speter (void) tcgetattr(fileno(stdin), &termios); 78251877Speter} 79251877Speter 80251877Spetervoid 81251877Spetersetioctls(void) 82251877Speter{ 83251877Speter (void) tcsetattr(fileno(stdin), TCSADRAIN, &termios); 84251877Speter} 85251877Speter 86251877Speter#ifdef SUSPEND 87251877Speter#include <signal.h> 88253895Speterint 89251877Speterdosuspend(void) 90253895Speter{ 91253895Speter#ifdef SIGTSTP 92253895Speter if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) { 93253895Speter settty(NULL); 94253895Speter (void) signal(SIGTSTP, SIG_DFL); 95253895Speter (void) kill(0, SIGTSTP); 96253895Speter gettty(); 97253895Speter setftty(); 98253895Speter docrt(); 99253895Speter } else { 100253895Speter pline("I don't think your shell has job control."); 101253895Speter } 102253895Speter#else /* SIGTSTP */ 103253895Speter pline("Sorry, it seems we have no SIGTSTP here. Try ! or S."); 104253895Speter#endif /* SIGTSTP */ 105253895Speter return(0); 106253895Speter} 107253895Speter#endif /* SUSPEND */ 108253895Speter