Compare commits

...

2 commits

Author SHA1 Message Date
Alexandre Dulaunoy d02412720b
Merge pull request #102 from the-real-tokai/fix-fdatasync-osx
Fix problematic fdatasync() call on macOS
2024-04-23 17:15:07 +02:00
Christian Rosentreter e5f2916b65
Fix problematic fdatasync() call on macOS
The fdatasync call generates a "implicit declaration of function 'fdatasync' is invalid in C99" warning when building for macOS (it's nowhere to be found in the system includes), but linking will eventually work fine because there is an unrelated syscall by the same name (different prototype), so it's not doing what it should. So lets not use it.
2024-04-16 17:49:06 +02:00

View file

@ -54,7 +54,11 @@ static int init_pcap_logger(void *data) {
}
static int deinit_pcap_logger(void) {
fdatasync(pcap_fd);
#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0)
fdatasync(pcap_fd);
#else
fsync(pcap_fd);
#endif
close(pcap_fd);
return 0;
}