summaryrefslogtreecommitdiff
path: root/Presence/monitortty.c
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-11-12 20:35:00 -0500
committerjoe <joe@jerkface.net>2017-11-12 20:35:00 -0500
commit5e8f82e436c03e1c59e69d5c9eb0e5a14284dd87 (patch)
tree1f5e8816e162e570131b8f4cfd90f7cb0b4c5fa7 /Presence/monitortty.c
parentd4288f5a9f87e3889a50a347ebad0a812f52938c (diff)
We no longer require root. (ConsoleWriter is disabled without).
Diffstat (limited to 'Presence/monitortty.c')
-rw-r--r--Presence/monitortty.c15
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
149void monitorTTY(int fd) { 149// Returns 0 on success.
150int 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
155void closeTTY() { 164void closeTTY() {