return 0;
len = loop_write(o->fd, o->obuf, o->n_obuf, false);
- if (len < 0) {
- log_error("error: cannot write to TTY (%zd): %s", len, strerror(-len));
- return len;
- }
+ if (len < 0)
+ return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
o->n_obuf = 0;
return r;
len = loop_write(o->fd, buf, size, false);
- if (len < 0) {
- log_error("error: cannot write to TTY (%zd): %s", len, strerror(-len));
- return len;
- }
+ if (len < 0)
+ return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len);
return 0;
}
if (t->pty) {
r = pty_resize(t->pty, t->output->in_width, t->output->in_height);
if (r < 0)
- log_error("error: pty_resize() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: pty_resize() (%d): %m", r);
}
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0)
- log_error("error: term_screen_resize() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: term_screen_resize() (%d): %m", r);
terminal_dirty(t);
if (t->pty) {
for (i = 0; i < num; ++i) {
r = pty_write(t->pty, vec[i].iov_base, vec[i].iov_len);
- if (r < 0) {
- log_error("error: cannot write to PTY (%d): %s", r, strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "error: cannot write to PTY (%d): %m", r);
}
}
n_str = term_utf8_decode(&t->utf8, &str, buf[i]);
for (j = 0; j < n_str; ++j) {
type = term_parser_feed(t->parser, &seq, str[j]);
- if (type < 0) {
- log_error("error: term_parser_feed() (%d): %s", type, strerror(-type));
- return type;
- }
+ if (type < 0)
+ return log_error_errno(type, "error: term_parser_feed() (%d): %m", type);
if (!t->is_menu) {
r = terminal_push_tmp(t, str[j]);
break;
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
- if (r < 0) {
- log_error("error: term_screen_feed_text() (%d): %s", r, strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "error: term_screen_feed_text() (%d): %m", r);
terminal_dirty(t);
break;
r = tcsetattr(t->in_fd, TCSANOW, &in_attr);
if (r < 0) {
- log_error("error: tcsetattr() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: tcsetattr() (%d): %m", r);
goto error;
}
r = tcsetattr(t->out_fd, TCSANOW, &out_attr);
if (r < 0) {
- log_error("error: tcsetattr() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: tcsetattr() (%d): %m", r);
goto error;
}
r = sd_event_default(&t->event);
if (r < 0) {
- log_error("error: sd_event_default() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sd_event_default() (%d): %m", r);
goto error;
}
r = sigprocmask_many(SIG_BLOCK, SIGINT, SIGQUIT, SIGTERM, SIGWINCH, SIGCHLD, -1);
if (r < 0) {
- log_error("error: sigprocmask_many() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sigprocmask_many() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGINT, NULL, NULL);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGQUIT, NULL, NULL);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGTERM, NULL, NULL);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
r = sd_event_add_signal(t->event, NULL, SIGWINCH, terminal_winch_fn, t);
if (r < 0) {
- log_error("error: sd_event_add_signal() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sd_event_add_signal() (%d): %m", r);
goto error;
}
t->is_dirty = true;
r = sd_event_add_time(t->event, &t->frame_timer, CLOCK_MONOTONIC, 0, 0, terminal_frame_timer_fn, t);
if (r < 0) {
- log_error("error: sd_event_add_time() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: sd_event_add_time() (%d): %m", r);
goto error;
}
r = term_screen_resize(t->screen, t->output->in_width, t->output->in_height);
if (r < 0) {
- log_error("error: term_screen_resize() (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: term_screen_resize() (%d): %m", r);
goto error;
}
assert_return(t, -EINVAL);
pid = pty_fork(&t->pty, t->event, terminal_pty_fn, t, t->output->in_width, t->output->in_height);
- if (pid < 0) {
- log_error("error: cannot fork PTY (%d): %s", pid, strerror(-pid));
- return pid;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(pid, "error: cannot fork PTY (%d): %m", pid);
+ else if (pid == 0) {
/* child */
char **argv = (char*[]){
out:
if (r < 0)
- log_error("error: terminal failed (%d): %s", r, strerror(-r));
+ log_error_errno(r, "error: terminal failed (%d): %m", r);
terminal_free(t);
return -r;
}