chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
logs-show: fix check of loop_read_exact
[elogind.git]
/
src
/
shared
/
pty.c
diff --git
a/src/shared/pty.c
b/src/shared/pty.c
index 11d76f825fd890d2569ba52924cf035047816424..0f80f4863b0e1f4bde990f777bd1290331ebe91c 100644
(file)
--- a/
src/shared/pty.c
+++ b/
src/shared/pty.c
@@
-44,18
+44,12
@@
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
-#include <pty.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
-#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/epoll.h>
#include <sys/epoll.h>
-#include <sys/eventfd.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <termios.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <termios.h>
@@
-67,7
+61,7
@@
#include "ring.h"
#include "util.h"
#include "ring.h"
#include "util.h"
-#define PTY_BUFSIZE
16384
+#define PTY_BUFSIZE
4096
enum {
PTY_ROLE_UNKNOWN,
enum {
PTY_ROLE_UNKNOWN,
@@
-105,6
+99,7
@@
int pty_new(Pty **out) {
pty->ref = 1;
pty->fd = -1;
pty->ref = 1;
pty->fd = -1;
+ pty->barrier = (Barrier) BARRIER_NULL;
pty->fd = posix_openpt(O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK);
if (pty->fd < 0)
pty->fd = posix_openpt(O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK);
if (pty->fd < 0)
@@
-127,7
+122,7
@@
int pty_new(Pty **out) {
if (r < 0)
return -errno;
if (r < 0)
return -errno;
- r = barrier_
init
(&pty->barrier);
+ r = barrier_
create
(&pty->barrier);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-193,13
+188,13
@@
int pty_get_fd(Pty *pty) {
}
int pty_make_child(Pty *pty) {
}
int pty_make_child(Pty *pty) {
-
char slave_name[1024]
;
+
_cleanup_free_ char *slave_name = NULL
;
int r, fd;
assert_return(pty, -EINVAL);
assert_return(pty_is_unknown(pty), -EALREADY);
int r, fd;
assert_return(pty, -EINVAL);
assert_return(pty_is_unknown(pty), -EALREADY);
- r = ptsname_
r(pty->fd, slave_name, sizeof(slave_name)
);
+ r = ptsname_
malloc(pty->fd, &slave_name
);
if (r < 0)
return -errno;
if (r < 0)
return -errno;
@@
-304,11
+299,11
@@
static int pty_dispatch_read(Pty *pty) {
/*
* We're edge-triggered, means we need to read the whole queue. This,
* however, might cause us to stall if the writer is faster than we
/*
* We're edge-triggered, means we need to read the whole queue. This,
* however, might cause us to stall if the writer is faster than we
- * are. Therefore,
we read twice and if the second read still returned
- *
data, we reschedule
.
+ * are. Therefore,
try reading as much as 8 times (32KiB) and only
+ *
bail out then
.
*/
*/
- for (i = 0; i <
2
; ++i) {
+ for (i = 0; i <
8
; ++i) {
len = read(pty->fd, pty->in_buf, sizeof(pty->in_buf) - 1);
if (len < 0) {
if (errno == EINTR)
len = read(pty->fd, pty->in_buf, sizeof(pty->in_buf) - 1);
if (len < 0) {
if (errno == EINTR)
@@
-549,16
+544,15
@@
int pty_signal(Pty *pty, int sig) {
}
int pty_resize(Pty *pty, unsigned short term_width, unsigned short term_height) {
}
int pty_resize(Pty *pty, unsigned short term_width, unsigned short term_height) {
- struct winsize ws;
+ struct winsize ws = {
+ .ws_col = term_width,
+ .ws_row = term_height,
+ };
assert_return(pty, -EINVAL);
assert_return(pty_is_open(pty), -ENODEV);
assert_return(pty_is_parent(pty), -ENODEV);
assert_return(pty, -EINVAL);
assert_return(pty_is_open(pty), -ENODEV);
assert_return(pty_is_parent(pty), -ENODEV);
- zero(ws);
- ws.ws_col = term_width;
- ws.ws_row = term_height;
-
/*
* This will send SIGWINCH to the pty slave foreground process group.
* We will also get one, but we don't need it.
/*
* This will send SIGWINCH to the pty slave foreground process group.
* We will also get one, but we don't need it.