default to gb_Deliver_CLEARONDELIVER == as multiuserenv are rare now
[LibreOffice.git] / dmake / quit.c
blob68ade197fd24caeaef65db3d7a5e529dc5f861b9
1 /* $RCSfile: quit.c,v $
2 -- $Revision: 1.8 $
3 -- last change: $Author: kz $ $Date: 2008-03-05 18:29:56 $
4 --
5 -- SYNOPSIS
6 -- End the dmake session.
7 --
8 -- DESCRIPTION
9 -- Handles dmake termination.
11 -- AUTHOR
12 -- Dennis Vadura, dvadura@dmake.wticorp.com
14 -- WWW
15 -- http://dmake.wticorp.com/
17 -- COPYRIGHT
18 -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved.
20 -- This program is NOT free software; you can redistribute it and/or
21 -- modify it under the terms of the Software License Agreement Provided
22 -- in the file <distribution-root>/readme/license.txt.
24 -- LOG
25 -- Use cvs log to obtain detailed change logs.
28 #include "extern.h"
30 static void _handle_quit ANSI((char*));
31 static int _quitting = 0; /* Set to 1 once Quit() is called for the
32 * first time. */
35 PUBLIC void
36 Quit( sig )/*
37 ======== Error or quit */
38 int sig;
40 int ret = ERROR_ABORT_VALUE;
42 if( sig == SIGINT )
43 fprintf(stderr, "Caught SIGINT. Trying to quit ...\n");
44 else
45 #ifdef SIGQUIT
46 /* MinGW, maybe others also, does not have SIGQUIT. */
47 if( sig == SIGQUIT )
48 fprintf(stderr, "Caught SIGQUIT. Trying to quit ...\n");
49 else
50 #endif
51 if( sig == 0 )
52 /* Don't be verbose during regular program termination. */
53 ret = ERROR_EXIT_VALUE;
54 else
55 fprintf(stderr, "Caught signal %d. Trying to quit ...\n", sig);
57 if( _quitting ) return; /* Guard to only quit once. */
58 _quitting = 1;
60 while( Closefile() != NIL( FILE ) );
62 /* CTRL-c sends SIGINT and CTRL-\ sends SIGQUIT to the parent and to all
63 * children. No need to kill them. */
64 if( sig != SIGINT
65 #ifdef SIGQUIT
66 /* MinGW, maybe others also, does not have SIGQUIT. */
67 && sig != SIGQUIT
68 #endif
70 /* This should be called Kill_all_processes(). */
71 Clean_up_processes();
73 /* Wait until all Processes are done. */
74 while( Wait_for_child(TRUE, -1) != -1 )
77 if( Current_target != NIL(CELL) )
78 Unlink_temp_files(Current_target);
80 if( _quitting == 0 ) _handle_quit( ".ERROR" );
82 Set_dir( Makedir ); /* No Error message if we can't do it */
83 Epilog( ret );
87 PUBLIC const int
88 in_quit( void )/*
89 =================
90 Called to check if we are already quitting.
91 (Only used in unix/runargv.c.) */
93 return _quitting;
96 static void
97 _handle_quit( err_target )/*
98 ============================
99 Called by Quit() to handle the execution of termination code
100 from within make */
101 char *err_target;
103 HASHPTR hp;
104 CELLPTR cp;
106 if( (hp = Get_name(err_target, Defs, FALSE)) != NIL(HASH) ) {
107 cp = hp->CP_OWNR;
108 Glob_attr |= A_IGNORE;
110 cp->ce_flag |= F_TARGET;
111 Make( cp, NIL(CELL) );
113 /* Beware! If the ".ERROR" target doesn't finish the following
114 * wait will never return!!! */
115 while( Wait_for_child(FALSE, -1) != -1 );