X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=main.c;h=bbec86005ece242888527c139d004e783d1b6f83;hp=4282e4a6a250fa7ac3cd519d3ea4fa0a837dd46b;hb=49ffd290f273417c62e395cbbcb65ab7d75cd36a;hpb=6f19c791d4fe0d9a6c59ebecb26156f17e80eb75 diff --git a/main.c b/main.c index 4282e4a..bbec860 100644 --- a/main.c +++ b/main.c @@ -90,7 +90,7 @@ retry: maxlen = LOG_BUF_SIZE - proc->log_buf_ofs; read_len = len = read(fd->fd, buf, maxlen); if (len < 0) { - if (errno == EAGAIN) + if (errno == EINTR) goto retry; goto out; @@ -99,9 +99,13 @@ retry: proc->log_buf_ofs += len; - cur = buf; + len = proc->log_buf_ofs; buf = proc->log_buf; - while (len > 0 && (cur = memchr(cur, '\n', len))) { + while (len > 0) { + cur = memchr(buf, '\n', len); + if (!cur) + break; + *cur = 0; if (!proc->log_overflow) @@ -116,7 +120,7 @@ retry: } if (buf > proc->log_buf && len > 0) - memmove(buf, proc->log_buf, len); + memmove(proc->log_buf, buf, len); if (len == LOG_BUF_SIZE) { if (!proc->log_overflow) { @@ -129,7 +133,7 @@ retry: } proc->log_buf_ofs = len; - if (read_len == maxlen) + if (read_len > 0) goto retry; out: @@ -219,7 +223,7 @@ netifd_kill_process(struct netifd_process *proc) if (!proc->uloop.pending) return; - kill(proc->uloop.pid, SIGTERM); + kill(proc->uloop.pid, SIGKILL); netifd_delete_process(proc); }