| 891 | /* Create the next output file. */ |
| 892 | |
| 893 | static void |
| 894 | create_output_file (void) |
| 895 | { |
| 896 | int nfiles = files_created; |
| 897 | bool fopen_ok; |
| 898 | int fopen_errno; |
| 899 | |
| 900 | output_filename = make_filename (nfiles); |
| 901 | |
| 902 | if (nfiles == INT_MAX) |
| 903 | { |
| 904 | fopen_ok = false; |
| 905 | fopen_errno = EOVERFLOW; |
| 906 | } |
| 907 | else |
| 908 | { |
| 909 | /* Create the output file in a critical section, to avoid races. */ |
| 910 | sigset_t oldset; |
| 911 | sigprocmask (SIG_BLOCK, &caught_signals, &oldset); |
| 912 | output_stream = fopen (output_filename, "w"); |
| 913 | fopen_ok = (output_stream != NULL); |
| 914 | fopen_errno = errno; |
| 915 | files_created = nfiles + fopen_ok; |
| 916 | sigprocmask (SIG_SETMASK, &oldset, NULL); |
| 917 | } |
| 918 | |
| 919 | if (! fopen_ok) |
| 920 | { |
| 921 | error (0, fopen_errno, "%s", quotef (output_filename)); |
| 922 | cleanup_fatal (); |
| 923 | } |
| 924 | bytes_written = 0; |
| 925 | } |
| 926 | |
| 927 | /* If requested, delete all the files we have created. This function |
| 928 | must be called only from critical sections. */ |
no test coverage detected