LCOV - code coverage report
Current view: top level - libreoffice/dmake - quit.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 31 54.8 %
Date: 2012-12-17 Functions: 1 3 33.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10