|
@@ -1179,6 +1179,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
|
fprintf(stderr, "cannot use both --output and --log-fd\n");
|
|
fprintf(stderr, "cannot use both --output and --log-fd\n");
|
|
usage_with_options(stat_usage, options);
|
|
usage_with_options(stat_usage, options);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (output_fd < 0) {
|
|
|
|
+ fprintf(stderr, "argument to --log-fd must be a > 0\n");
|
|
|
|
+ usage_with_options(stat_usage, options);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!output) {
|
|
if (!output) {
|
|
struct timespec tm;
|
|
struct timespec tm;
|
|
mode = append_file ? "a" : "w";
|
|
mode = append_file ? "a" : "w";
|
|
@@ -1190,7 +1196,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
|
}
|
|
}
|
|
clock_gettime(CLOCK_REALTIME, &tm);
|
|
clock_gettime(CLOCK_REALTIME, &tm);
|
|
fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
|
|
fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
|
|
- } else if (output_fd != 2) {
|
|
|
|
|
|
+ } else if (output_fd > 0) {
|
|
mode = append_file ? "a" : "w";
|
|
mode = append_file ? "a" : "w";
|
|
output = fdopen(output_fd, mode);
|
|
output = fdopen(output_fd, mode);
|
|
if (!output) {
|
|
if (!output) {
|