Logging: Add LOG_DEVEL_LOG_LEAKING_FDS

This commit is contained in:
matt335672
2023-04-21 16:04:06 +01:00
parent cf9e07d341
commit 1c798cee47
2 changed files with 45 additions and 0 deletions
+24
View File
@@ -1173,3 +1173,27 @@ getFormattedDateTime(char *replybuf, int bufsize)
return replybuf;
}
/*****************************************************************************/
#ifdef USE_DEVEL_LOGGING
void
log_devel_leaking_fds(const char *exe, int min, int max)
{
struct list *fd_list = g_get_open_fds(min, max);
if (fd_list != NULL)
{
int i;
for (i = 0 ; i < fd_list->count ; ++i)
{
int fd = (int)fd_list->items[i];
if (g_file_get_cloexec(fd) == 0)
{
LOG_DEVEL(LOG_LEVEL_WARNING,
"File descriptor %d is not CLOEXEC when running %s",
fd, exe);
}
}
}
}
#endif // USE_DEVEL_LOGGING