[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] Proposed solution to Debian Bug#143485
From: |
Robert Elz |
Subject: |
Re: [Nmh-workers] Proposed solution to Debian Bug#143485 |
Date: |
Fri, 26 Aug 2005 13:23:58 +0700 |
Date: Fri, 26 Aug 2005 01:39:55 +0200
From: Harald Geyer <address@hidden>
Message-ID: <address@hidden>
execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
- fprintf (stderr, "unable to exec ");
- perror (mhlproc);
+ write(2, "unable to exec ", 15);
+ write(2, mhlproc, strlen(mhlproc));
+ write(2, strerror(errno), strlen(strerror(errno)));
The code you changed there is obviously broken (apart from using printf after
a vfork), but your replacement isn't a lot better - the "strerror(errno)"
calls (which you really should not do twice ... use a variable and save the
result!) the way you have it is getting the errno set from the write(2,
mhlproc, strlen(mhlproc)) sys call, where I suspect that you wanted the
errno from the execlp (which must have failed or the code wouldn't be being
executed).
write this as
char *errstr;
[...]
execlp(...);
errstr = strerror(errno);
write(2,....);
write(2,....);
/* maybe: write(2, ": ", 2); */
write(2, errstr, strlen(errstr));
write(2, "\n", 1);
kre