ubus: split address from mask in interface status
[project/netifd.git] / main.c
diff --git a/main.c b/main.c
index bed0edd..bbec860 100644 (file)
--- 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) {
@@ -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);
 }