xref: /netbsd-src/sys/arch/atari/stand/tostools/libtos/xexit.c (revision df7f595ecd6efe54ea7c11083e2dbf711cad4b31)
1*df7f595eScegger /*	$NetBSD: xexit.c,v 1.3 2009/03/18 10:22:26 cegger Exp $	*/
2b24ea33cSleo 
3b24ea33cSleo /*
4b24ea33cSleo  * Copyright (c) 1995 Waldi Ravens.
5b24ea33cSleo  * All rights reserved.
6b24ea33cSleo  *
7b24ea33cSleo  * Redistribution and use in source and binary forms, with or without
8b24ea33cSleo  * modification, are permitted provided that the following conditions
9b24ea33cSleo  * are met:
10b24ea33cSleo  * 1. Redistributions of source code must retain the above copyright
11b24ea33cSleo  *    notice, this list of conditions and the following disclaimer.
12b24ea33cSleo  * 2. Redistributions in binary form must reproduce the above copyright
13b24ea33cSleo  *    notice, this list of conditions and the following disclaimer in the
14b24ea33cSleo  *    documentation and/or other materials provided with the distribution.
15b24ea33cSleo  * 3. All advertising materials mentioning features or use of this software
16b24ea33cSleo  *    must display the following acknowledgement:
17b24ea33cSleo  *        This product includes software developed by Waldi Ravens.
18b24ea33cSleo  * 4. The name of the author may not be used to endorse or promote products
19b24ea33cSleo  *    derived from this software without specific prior written permission.
20b24ea33cSleo  *
21b24ea33cSleo  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22b24ea33cSleo  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23b24ea33cSleo  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24b24ea33cSleo  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25b24ea33cSleo  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26b24ea33cSleo  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27b24ea33cSleo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28b24ea33cSleo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29b24ea33cSleo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30b24ea33cSleo  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31b24ea33cSleo  */
32b24ea33cSleo 
33b24ea33cSleo #include <stdio.h>
34b24ea33cSleo #include <stdlib.h>
35b24ea33cSleo #include <unistd.h>
36b24ea33cSleo #include "libtos.h"
37b24ea33cSleo 
38b24ea33cSleo static int	wait_for_key = 0;
39b24ea33cSleo 
40b24ea33cSleo void
set_wait_for_key(void)41*df7f595eScegger set_wait_for_key(void)
42b24ea33cSleo {
43b24ea33cSleo 	if (isatty(STDERR_FILENO))
44b24ea33cSleo 		wait_for_key = 1;
45b24ea33cSleo }
46b24ea33cSleo 
47b24ea33cSleo void
press_any_key(void)48*df7f595eScegger press_any_key(void)
49b24ea33cSleo {
50b24ea33cSleo 	if (wait_for_key)
51b24ea33cSleo 		(void)key_wait(NULL);
52b24ea33cSleo }
53b24ea33cSleo 
54b24ea33cSleo void
xexit(int status)55454af1c0Sdsl xexit(int status)
56b24ea33cSleo {
57b24ea33cSleo 	press_any_key();
58b24ea33cSleo 	exit(status);
59b24ea33cSleo }
60