diff options
Diffstat (limited to 'Presence/monitortty.c')
-rw-r--r-- | Presence/monitortty.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Presence/monitortty.c b/Presence/monitortty.c index a9a095cf..7582aa56 100644 --- a/Presence/monitortty.c +++ b/Presence/monitortty.c | |||
@@ -146,10 +146,19 @@ void *write_vtch(void *pfd) { | |||
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | void monitorTTY(int fd) { | 149 | // Returns 0 on success. |
150 | int monitorTTY(int fd) { | ||
151 | int er = -1, dev = -1; | ||
150 | pthread_mutex_init(&mu,NULL); | 152 | pthread_mutex_init(&mu,NULL); |
151 | // printf ("Hello world.\n"); | 153 | // Ensure we can open a device before we bother forking a thread. |
152 | pthread_create (&mt, NULL, write_vtch, (void*)(intptr_t)fd); | 154 | dev = ttyfd(); |
155 | if( dev != -1 ) { | ||
156 | er = pthread_create (&mt, NULL, write_vtch, (void*)(intptr_t)fd); | ||
157 | return er; | ||
158 | } | ||
159 | else { | ||
160 | return -1; | ||
161 | } | ||
153 | } | 162 | } |
154 | 163 | ||
155 | void closeTTY() { | 164 | void closeTTY() { |