| 2376 | Return zero if successful, an exit status otherwise. */ |
| 2377 | |
| 2378 | static int |
| 2379 | synchronize_output (void) |
| 2380 | { |
| 2381 | int exit_status = 0; |
| 2382 | int mask = conversions_mask; |
| 2383 | conversions_mask &= ~ (C_FDATASYNC | C_FSYNC); |
| 2384 | |
| 2385 | if ((mask & C_FDATASYNC) && ifdatasync (STDOUT_FILENO) != 0) |
| 2386 | { |
| 2387 | if (errno != ENOSYS && errno != EINVAL) |
| 2388 | { |
| 2389 | diagnose (errno, _("fdatasync failed for %s"), quoteaf (output_file)); |
| 2390 | exit_status = EXIT_FAILURE; |
| 2391 | } |
| 2392 | mask |= C_FSYNC; |
| 2393 | } |
| 2394 | |
| 2395 | if ((mask & C_FSYNC) && ifsync (STDOUT_FILENO) != 0) |
| 2396 | { |
| 2397 | diagnose (errno, _("fsync failed for %s"), quoteaf (output_file)); |
| 2398 | return EXIT_FAILURE; |
| 2399 | } |
| 2400 | |
| 2401 | return exit_status; |
| 2402 | } |
| 2403 | |
| 2404 | int |
| 2405 | main (int argc, char **argv) |
no test coverage detected