diff --git a/src/calibre/devices/mtp/unix/libmtp.c b/src/calibre/devices/mtp/unix/libmtp.c index 1716265ec7..920ddde3d1 100644 --- a/src/calibre/devices/mtp/unix/libmtp.c +++ b/src/calibre/devices/mtp/unix/libmtp.c @@ -8,7 +8,9 @@ #define UNICODE #include - +#include +#include +#include #include #include @@ -728,7 +730,20 @@ initlibmtp(void) { if (MTPError == NULL) return; PyModule_AddObject(m, "MTPError", MTPError); + // Redirect stdout to get rid of the annoying message about mtpz. Really, + // who designs a library without anyway to control/redirect the debugging + // output, and hardcoded paths that cannot be changed? + int bak, new; + fflush(stdout); + bak = dup(STDOUT_FILENO); + new = open("/dev/null", O_WRONLY); + dup2(new, STDOUT_FILENO); + close(new); LIBMTP_Init(); + fflush(stdout); + dup2(bak, STDOUT_FILENO); + close(bak); + LIBMTP_Set_Debug(LIBMTP_DEBUG_NONE); Py_INCREF(&DeviceType);