zic on multi-processor systems
Ken Pizzini
ken at halcyon.com
Sun Feb 2 23:22:28 UTC 1997
Urlich Drepper's recent patch has a minor problem: the call
to itsdir() can reset the errno so that a misleading message
may be reported for a mkdir() failure; I propose the following
patch instead:
--- zic.c.orig Mon Jan 20 16:02:25 1997
+++ zic.c Sun Feb 2 15:15:41 1997
@@ -2126,15 +2126,20 @@
if (!itsdir(name)) {
/*
** It doesn't seem to exist, so we try to create it.
+ ** Double check the return. Someone may be one
+ ** step ahead of us.
*/
if (mkdir(name, 0755) != 0) {
- const char *e = strerror(errno);
+ int sverr = errno;
+ if (!itsdir(name)) {
+ const char *e = strerror(sverr);
- (void) fprintf(stderr,
- _("%s: Can't create directory %s: %s\n"),
- progname, name, e);
- ifree(name);
- return -1;
+ (void) fprintf(stderr,
+ _("%s: Can't create directory %s: %s\n"),
+ progname, name, e);
+ ifree(name);
+ return -1;
+ }
}
}
*cp = '/';
Due to reindentation of a block that looks uglier than it really is;
for human consumption, here is the patch again, but using the "-b"
option to diff:
if (!itsdir(name)) {
/*
** It doesn't seem to exist, so we try to create it.
+ ** Double check the return. Someone may be one
+ ** step ahead of us.
*/
if (mkdir(name, 0755) != 0) {
+ int sverr = errno;
+ if (!itsdir(name)) {
const char *e = strerror(errno);
(void) fprintf(stderr,
_("%s: Can't create directory %s: %s\n"),
progname, name, e);
ifree(name);
return -1;
+ }
}
}
--Ken Pizzini
More information about the tz
mailing list