New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the SIGWINCH race and added a check for EINTR in write_all() #18

Closed
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+7 −5
Diff settings

Always

Just for now

Removed the SIGWINCH race and added a check for EINTR in write_all()

  • Loading branch information...
robryk committed Feb 27, 2012
commit f1b78326793acbd16a80731b82904afd640a61c6
View
@@ -97,15 +97,18 @@ int writeall(int fd, const void *buf, ssize_t count) {
ssize_t rv;
while (count > 0) {
rv = write(fd, buf, count);
if (rv < 0)
if (rv < 0) {
if (errno == EINTR)
continue;
return rv;
}
count -= rv;
buf += rv;
}
return 0;
}
int winch_happened = 0;
volatile int winch_happened = 0;
void do_winch(int signal) {
winch_happened = 1;
@@ -117,9 +120,8 @@ void do_proxy(int pty) {
fd_set set;
while (1) {
if (winch_happened) {
resize_pty(pty);
/* FIXME: racy against a second resize */
winch_happened = 0;
resize_pty(pty);
}
FD_ZERO(&set);
FD_SET(0, &set);
@@ -241,11 +243,11 @@ int main(int argc, char **argv) {
}
setup_raw(&saved_termios);
resize_pty(pty);
memset(&act, 0, sizeof act);
act.sa_handler = do_winch;
act.sa_flags = 0;
sigaction(SIGWINCH, &act, NULL);
resize_pty(pty);
do_proxy(pty);
tcsetattr(0, TCSANOW, &saved_termios);
ProTip! Use n and p to navigate between commits in a pull request.