-/* $OpenBSD: dd.c,v 1.28 2021/10/24 21:24:21 deraadt Exp $ */
+/* $OpenBSD: dd.c,v 1.29 2024/07/12 14:30:27 deraadt Exp $ */
/* $NetBSD: dd.c,v 1.6 1996/02/20 19:29:06 jtc Exp $ */
/*-
jcl(argv);
setup();
- (void)signal(SIGINFO, summaryx);
- (void)signal(SIGINT, terminate);
+ (void)signal(SIGINFO, sig_summary);
+ (void)signal(SIGINT, sig_terminate);
- atexit(summary);
+ atexit(exit_summary);
if (cpy_cnt != (size_t)-1) {
while (files_cnt--)
if (!(ddflags & C_NOERROR))
err(1, "%s", in.name);
warn("%s", in.name);
- summary();
+ sig_summary(0);
/*
* If it's not a tape drive or a pipe, seek past the
-/* $OpenBSD: extern.h,v 1.9 2014/03/27 15:32:13 tedu Exp $ */
+/* $OpenBSD: extern.h,v 1.10 2024/07/12 14:30:27 deraadt Exp $ */
/* $NetBSD: extern.h,v 1.7 1996/02/20 19:29:07 jtc Exp $ */
/*-
void jcl(char **);
void pos_in(void);
void pos_out(void);
-void summary(void);
-void summaryx(int);
-void terminate(int);
+void exit_summary(void);
+void sig_summary(int);
+void sig_terminate(int);
void unblock(void);
void unblock_close(void);
-/* $OpenBSD: misc.c,v 1.24 2024/07/12 07:22:44 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.25 2024/07/12 14:30:27 deraadt Exp $ */
/* $NetBSD: misc.c,v 1.4 1995/03/21 09:04:10 cgd Exp $ */
/*-
#include "dd.h"
#include "extern.h"
+/* SIGINFO handler */
void
-summary(void)
+sig_summary(int notused)
{
+ int save_errno = errno;
struct timespec elapsed, now;
double nanosecs;
(long long)elapsed.tv_sec, elapsed.tv_nsec / 1000000,
((double)st.bytes * 1000000000) / nanosecs);
}
+ errno = save_errno;
}
+/* SIGINT handler */
void
-summaryx(int notused)
+sig_terminate(int signo)
{
- int save_errno = errno;
-
- summary(); /* XXX signal race, dprintf floating point */
- errno = save_errno;
+ sig_summary(0);
+ _exit(128 + signo);
}
+/* atexit variation to summarize */
void
-terminate(int signo)
+exit_summary(void)
{
- summary(); /* XXX signal race, dprintf floating point */
- _exit(128 + signo);
+ sig_summary(0);
}
-/* $OpenBSD: position.c,v 1.11 2019/06/28 13:34:59 deraadt Exp $ */
+/* $OpenBSD: position.c,v 1.12 2024/07/12 14:30:27 deraadt Exp $ */
/* $NetBSD: position.c,v 1.4 1995/03/21 09:04:12 cgd Exp $ */
/*-
if (!warned) {
warn("%s", in.name);
warned = 1;
- summary();
+ sig_summary(0);
}
continue;
}