mirror of git://git.suckless.org/sbase
Incomplete output is not an error
This commit is contained in:
parent
29bc0ce130
commit
135f6012cb
15
dmesg.c
15
dmesg.c
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static int dmesg_show(int fd, const void *buf, size_t n);
|
static void dmesg_show(int fd, const void *buf, size_t n);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SYSLOG_ACTION_READ_ALL = 3,
|
SYSLOG_ACTION_READ_ALL = 3,
|
||||||
|
@ -60,9 +60,7 @@ main(int argc, char *argv[])
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
eprintf("klogctl:");
|
eprintf("klogctl:");
|
||||||
|
|
||||||
n = dmesg_show(STDOUT_FILENO, buf, n);
|
dmesg_show(STDOUT_FILENO, buf, n);
|
||||||
if (n < 0)
|
|
||||||
eprintf("dmesg_show:");
|
|
||||||
|
|
||||||
if (cflag && klogctl(SYSLOG_ACTION_CLEAR, NULL, 0) < 0)
|
if (cflag && klogctl(SYSLOG_ACTION_CLEAR, NULL, 0) < 0)
|
||||||
eprintf("klogctl:");
|
eprintf("klogctl:");
|
||||||
|
@ -71,16 +69,15 @@ main(int argc, char *argv[])
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
dmesg_show(int fd, const void *buf, size_t n)
|
dmesg_show(int fd, const void *buf, size_t n)
|
||||||
{
|
{
|
||||||
const char *p = buf;
|
const char *p = buf;
|
||||||
ssize_t r;
|
ssize_t r;
|
||||||
|
|
||||||
r = write(fd, p, n);
|
r = write(fd, p, n);
|
||||||
if (r < 0 || (size_t)r != n)
|
if (r < 0)
|
||||||
return -1;
|
eprintf("write:");
|
||||||
if (p[n - 1] != '\n')
|
if (r > 0 && p[r - 1] != '\n')
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue