Commit 875f4c85 authored by Austin Seipp's avatar Austin Seipp
Browse files

rts: delint/detab/dewhitespace TTY.c


Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent 3e0e489e
...@@ -27,8 +27,9 @@ static void *saved_termios[3] = {NULL,NULL,NULL}; ...@@ -27,8 +27,9 @@ static void *saved_termios[3] = {NULL,NULL,NULL};
void* void*
__hscore_get_saved_termios(int fd) __hscore_get_saved_termios(int fd)
{ {
return (0 <= fd && fd < (int)(sizeof(saved_termios) / sizeof(*saved_termios))) ? return (0 <= fd &&
saved_termios[fd] : NULL; fd < (int)(sizeof(saved_termios) / sizeof(*saved_termios))) ?
saved_termios[fd] : NULL;
} }
void void
...@@ -47,19 +48,20 @@ resetTerminalSettings (void) ...@@ -47,19 +48,20 @@ resetTerminalSettings (void)
// if we changed them. See System.Posix.Internals.tcSetAttr for // if we changed them. See System.Posix.Internals.tcSetAttr for
// more details, including the reason we termporarily disable // more details, including the reason we termporarily disable
// SIGTTOU here. // SIGTTOU here.
{ {
int fd; int fd;
sigset_t sigset, old_sigset; sigset_t sigset, old_sigset;
sigemptyset(&sigset); sigemptyset(&sigset);
sigaddset(&sigset, SIGTTOU); sigaddset(&sigset, SIGTTOU);
sigprocmask(SIG_BLOCK, &sigset, &old_sigset); sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
for (fd = 0; fd <= 2; fd++) { for (fd = 0; fd <= 2; fd++) {
struct termios* ts = (struct termios*)__hscore_get_saved_termios(fd); struct termios* ts =
if (ts != NULL) { (struct termios*)__hscore_get_saved_termios(fd);
tcsetattr(fd,TCSANOW,ts); if (ts != NULL) {
} tcsetattr(fd,TCSANOW,ts);
} }
sigprocmask(SIG_SETMASK, &old_sigset, NULL); }
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
} }
#endif #endif
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment