cmdedit: fix breakage
[oweals/busybox.git] / runit / svlogd.c
index 8e012d2392b5fad3b284f12036fca0199d6639cb..b089c54987ec4c891184acc2b6dc4e0e88a9ebaa 100644 (file)
@@ -141,26 +141,26 @@ static unsigned processorstart(struct logdir *ld)
                sig_unblock(sig_term);
                sig_unblock(sig_alarm);
                sig_unblock(sig_hangup);
-               
+
                if (verbose)
                        bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave);
                fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY);
                if (fd_move(0, fd) == -1)
                        bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
                ld->fnsave[26] = 't';
-               fd = xopen3(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT, 0644);
+               fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
                if (fd_move(1, fd) == -1)
                        bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
                fd = open_read("state");
                if (fd == -1) {
                        if (errno != ENOENT)
                                bb_perror_msg_and_die(FATAL"cannot %s processor %s", "open state for", ld->name);
-                       close(xopen3("state", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT, 0644));
+                       close(xopen("state", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT));
                        fd = xopen("state", O_RDONLY|O_NDELAY);
                }
                if (fd_move(4, fd) == -1)
                        bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
-               fd = xopen3("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT, 0644);
+               fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
                if (fd_move(5, fd) == -1)
                        bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
 
@@ -262,7 +262,7 @@ static unsigned rotate(struct logdir *ld)
                return 0;
        }
        if (ld->ppid)
-               while(!processorstop(ld))
+               while (!processorstop(ld))
                        /* wait */;
 
        while (fchdir(ld->fddir) == -1)
@@ -549,12 +549,12 @@ static unsigned logdir_open(struct logdir *ld, const char *fn)
        coe(ld->fdcur);
        while (fchmod(ld->fdcur, 0644) == -1)
                pause2cannot("set mode of current", ld->name);
-       
+
        if (verbose) {
                if (i == 0) bb_error_msg(INFO"append: %s/current", ld->name);
                else bb_error_msg(INFO"new: %s/current", ld->name);
        }
-       
+
        while (fchdir(fdwdir) == -1)
                pause1cannot("change to initial working directory");
        return 1;
@@ -569,7 +569,7 @@ static void logdirs_reopen(void)
        tmaxflag = 0;
        taia_now(&now);
        for (l = 0; l < dirn; ++l) {
-               logdir_close(&dir[l]);    
+               logdir_close(&dir[l]);
                if (logdir_open(&dir[l], fndir[l])) ok = 1;
        }
        if (!ok) fatalx("no functional log directories");
@@ -830,12 +830,8 @@ int svlogd_main(int argc, char **argv)
                        if (ld->fddir == -1) continue;
                        if (ld->inst)
                                logmatch(ld);
-                       if (ld->matcherr == 'e') {
-                               fprintf(stderr, "%.*s%s",
-                                               printlen, line,
-                                               (ch != '\n') ? "...\n" : ""
-                               );
-                       }
+                       if (ld->matcherr == 'e')
+                               full_write(2, line, printlen);
                        if (ld->match != '+') continue;
                        buffer_pwrite(i, line, printlen);
                }
@@ -859,6 +855,8 @@ int svlogd_main(int argc, char **argv)
                        /* linelen == no of chars incl. '\n' (or == stdin_cnt) */
                        for (i = 0; i < dirn; ++i) {
                                if (dir[i].fddir == -1) continue;
+                               if (dir[i].matcherr == 'e')
+                                       full_write(2, lineptr, linelen);
                                if (dir[i].match != '+') continue;
                                buffer_pwrite(i, lineptr, linelen);
                        }