summaryrefslogtreecommitdiff
path: root/Presence/monitortty.c
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-06-17 18:03:50 -0400
committerjoe <joe@jerkface.net>2013-06-17 18:03:50 -0400
commit7e8af335398be37523ff19244225b84d48e027ff (patch)
treea934d4e9230432480a392c0ef56d1b47bdb94118 /Presence/monitortty.c
parent6f87525d0b6c6ce3ae397b84bc237de92c805b33 (diff)
cleaner debug output
Diffstat (limited to 'Presence/monitortty.c')
-rw-r--r--Presence/monitortty.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Presence/monitortty.c b/Presence/monitortty.c
index 7b5dc82c..675abe5c 100644
--- a/Presence/monitortty.c
+++ b/Presence/monitortty.c
@@ -110,7 +110,7 @@ int tty = -1;
110 110
111void *write_vtch(void *pfd) { 111void *write_vtch(void *pfd) {
112 int fd = (int)(intptr_t)pfd; 112 int fd = (int)(intptr_t)pfd;
113 printf("START write_vtch fd=%i\n",fd); 113 printf("started VT_WAITEVENT loop fd=%i\n",fd);
114 pthread_mutex_lock(&mu); 114 pthread_mutex_lock(&mu);
115 tty = ttyfd(); 115 tty = ttyfd();
116 pthread_mutex_unlock(&mu); 116 pthread_mutex_unlock(&mu);
@@ -131,6 +131,7 @@ void *write_vtch(void *pfd) {
131 } 131 }
132 do { 132 do {
133 vt_wait(tty); 133 vt_wait(tty);
134 // printf("vt_wait() finished. tty=%d fd=%d\n",tty,fd);
134 active_tty = get_active(tty); 135 active_tty = get_active(tty);
135 } while (active_tty==reported_tty); 136 } while (active_tty==reported_tty);
136 } 137 }
@@ -138,7 +139,7 @@ void *write_vtch(void *pfd) {
138 // TODO: 139 // TODO:
139 // use VT_GETSTATE 140 // use VT_GETSTATE
140 // use VT_WAITEVENT 141 // use VT_WAITEVENT
141 printf("QUIT write_vtch\n"); 142 printf("stopped VT_WAITEVENT loop\n");
142 tty = -1; 143 tty = -1;
143 pthread_mutex_destroy(&mu); 144 pthread_mutex_destroy(&mu);
144 return NULL; 145 return NULL;
@@ -147,7 +148,7 @@ void *write_vtch(void *pfd) {
147 148
148void monitorTTY(int fd) { 149void monitorTTY(int fd) {
149 pthread_mutex_init(&mu,NULL); 150 pthread_mutex_init(&mu,NULL);
150 printf ("Hello world.\n"); 151 // printf ("Hello world.\n");
151 pthread_create (&mt, NULL, write_vtch, (void*)(intptr_t)fd); 152 pthread_create (&mt, NULL, write_vtch, (void*)(intptr_t)fd);
152} 153}
153 154
@@ -158,8 +159,9 @@ void closeTTY() {
158 active = get_active(tty); 159 active = get_active(tty);
159 fd = tty; 160 fd = tty;
160 pthread_mutex_unlock(&mu); 161 pthread_mutex_unlock(&mu);
161 pthread_cancel(mt); 162 // pthread_cancel(mt);
162 char cmd[40]; cmd[39] = '\0'; 163 char cmd[40]; cmd[39] = '\0';
164 // Hack to wake up from VT_WAITEVENT ioctl
163 snprintf(cmd,39,"chvt %i;chvt %i",active+1,active); 165 snprintf(cmd,39,"chvt %i;chvt %i",active+1,active);
164 system(cmd); 166 system(cmd);
165 pthread_join(mt,NULL); 167 pthread_join(mt,NULL);