Commit 50055102 authored by spiiroin's avatar spiiroin

[debug] Use wrapper for popen() calls. Fixes MER#1774

Calling popen() function indicates that usb-moded mainloop is blocked until
the subprocess finishes and it is difficult to tell whether such things
occur or not.

When in verbose mode, log subprocesses executed via popen().
Signed-off-by: spiiroin's avatarSimo Piiroinen <>
parent c2d824da
......@@ -363,7 +363,7 @@ static void report_mass_storage_blocker(const char *mountpoint, int try)
lsof_command = g_strconcat("lsof ", mountpoint, NULL);
if( (stream = popen(lsof_command, "r")) )
if( (stream = usb_moded_popen(lsof_command, "r")) )
char *text = 0;
size_t size = 0;
......@@ -1147,6 +1147,18 @@ usb_moded_system_(const char *file, int line, const char *func,
return rc;
/** Wrapper to give visibility subprocesses usb-moded is invoking via popen()
usb_moded_popen_(const char *file, int line, const char *func,
const char *command, const char *type)
log_debug("EXEC %s; from %s:%d: %s()",
command, file, line, func);
return popen(command, type);
/** Wrapper to give visibility to blocking sleeps usb-moded is making
......@@ -99,6 +99,9 @@ void usb_moded_stop(int exitcode);
int usb_moded_system_(const char *file, int line, const char *func, const char *command);
#define usb_moded_system(command) usb_moded_system_(__FILE__,__LINE__,__FUNCTION__,(command))
FILE *usb_moded_popen_(const char *file, int line, const char *func, const char *command, const char *type);
#define usb_moded_popen(command, type) usb_moded_popen_(__FILE__,__LINE__,__FUNCTION__,(command),(type))
void usb_moded_usleep_(const char *file, int line, const char *func, useconds_t usec);
#define usb_moded_usleep(usec) usb_moded_usleep_(__FILE__,__LINE__,__FUNCTION__,(usec))
#define usb_moded_msleep(msec) usb_moded_usleep_(__FILE__,__LINE__,__FUNCTION__,(msec)*1000)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment