~ubuntu-branches/ubuntu/maverick/texinfo/maverick

« back to all changes in this revision

Viewing changes to lib/xexit.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2005-10-28 15:10:30 UTC
  • mto: (2.1.1 dapper) (3.1.4 hardy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051028151030-9nsf2s2k2z3fktjt
Tags: upstream-4.8
ImportĀ upstreamĀ versionĀ 4.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* xexit.c -- exit with attention to return values and closing stdout.
2
 
   $Id: xexit.c,v 1.5 1999/02/19 14:13:51 karl Exp $
 
2
   $Id: xexit.c,v 1.5 2004/04/11 17:56:46 karl Exp $
3
3
 
4
 
   Copyright (C) 1999 Free Software Foundation, Inc.
 
4
   Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc.
5
5
 
6
6
   This program is free software; you can redistribute it and/or modify
7
7
   it under the terms of the GNU General Public License as published by
41
41
#endif /* not EXIT_SUCCESS */
42
42
 
43
43
 
44
 
/* Flush stdout first, exit if failure.  Otherwise, if EXIT_STATUS is
45
 
   zero, exit successfully, else unsuccessfully.  */
46
 
        
 
44
/* Flush stdout first, exit if failure (therefore, xexit should be
 
45
   called to exit every program, not just `return' from main).
 
46
   Otherwise, if EXIT_STATUS is zero, exit successfully, else
 
47
   unsuccessfully.  */
 
48
 
47
49
void
48
 
xexit (exit_status)
49
 
     int exit_status;
 
50
xexit (int exit_status)
50
51
{
51
52
  if (ferror (stdout))
52
53
    {
53
 
      fprintf (stderr, "ferror on stdout");
 
54
      fputs (_("ferror on stdout\n"), stderr);
54
55
      exit_status = 1;
55
56
    }
56
57
  else if (fflush (stdout) != 0)
57
58
    {
58
 
      fprintf (stderr, "fflush error on stdout");
 
59
      fputs (_("fflush error on stdout\n"), stderr);
59
60
      exit_status = 1;
60
61
    }
61
 
  
 
62
 
62
63
  exit_status = exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
63
 
  
 
64
 
64
65
  exit (exit_status);
65
66
}
66
67