diff --git a/libsrc/common/perror.c b/libsrc/common/perror.c index 814152e29..afe4be996 100644 --- a/libsrc/common/perror.c +++ b/libsrc/common/perror.c @@ -13,11 +13,16 @@ void perror (const char* msg) -{ - if (msg) { - fprintf (stderr, "%s: ", msg); +{ + /* Fetch the message that corresponds to errno */ + const char* errormsg = strerror (errno); + + /* Different output depending on msg */ + if (msg) { + fprintf (stderr, "%s: %s\n", msg, errormsg); + } else { + fprintf (stderr, "%s\n", errormsg); } - fprintf (stderr, "%s\n", strerror (errno)); }