IO (Linux): add detailed error messages for ffProcessAppendStdOut

This commit is contained in:
李通洲
2023-02-23 11:13:50 +08:00
parent 695e3cc692
commit 52c304ecae
2 changed files with 34 additions and 4 deletions
+19
View File
@@ -101,4 +101,23 @@ static inline void ffUnsuppressIO(bool* suppressed)
void ffListFilesRecursively(const char* path);
static inline bool wrapClose(FFNativeFD* pfd)
{
assert(pfd);
#ifndef WIN32
if (*pfd < 0)
return false;
close(*pfd);
#else
// https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
if (*pfd == NULL || *pfd == INVALID_HANDLE_VALUE)
return false;
CloseHandle(*pfd);
#endif
return true;
}
#define FF_AUTO_CLOSE_FD __attribute__((__cleanup__(wrapClose)))
#endif // FF_INCLUDED_common_io_io