comparison common.cpp @ 83:af7cf6f7282c

* ioctl fixes for OS/X
author Chris Cannam
date Mon, 22 Nov 2010 16:02:13 +0000
parents 32fa40c3d174
children 8a4e26dc3182
comparison
equal deleted inserted replaced
82:b0a90ac84b8b 83:af7cf6f7282c
157 DEBUG << "stdin is not a terminal" << endl; 157 DEBUG << "stdin is not a terminal" << endl;
158 } else { 158 } else {
159 DEBUG << "stdin is a terminal, detaching from it" << endl; 159 DEBUG << "stdin is a terminal, detaching from it" << endl;
160 if (ioctl(0, TIOCNOTTY, NULL) < 0) { 160 if (ioctl(0, TIOCNOTTY, NULL) < 0) {
161 perror("ioctl failed"); 161 perror("ioctl failed");
162 DEBUG << "ioctl for TIOCNOTTY failed (errno = " << errno << ")" << endl; 162 DEBUG << "ioctl for TIOCNOTTY on stdin failed (errno = " << errno << ")" << endl;
163 } else { 163 } else {
164 DEBUG << "ioctl for TIOCNOTTY succeeded" << endl; 164 DEBUG << "ioctl for TIOCNOTTY on stdin succeeded" << endl;
165 } 165 return;
166 return; 166 }
167 } 167 }
168 168
169 int ttyfd = open("/dev/tty", O_RDWR); 169 int ttyfd = open("/dev/tty", O_RDWR);
170 if (ttyfd < 0) { 170 if (ttyfd < 0) {
171 DEBUG << "failed to open controlling terminal" << endl; 171 DEBUG << "failed to open controlling terminal" << endl;
172 } else { 172 } else {
173 if (ioctl(ttyfd, TIOCNOTTY, NULL) < 0) { 173 if (ioctl(ttyfd, TIOCNOTTY, NULL) < 0) {
174 perror("ioctl failed"); 174 perror("ioctl failed");
175 DEBUG << "ioctl for TIOCNOTTY failed (errno = " << errno << ")" << endl; 175 DEBUG << "ioctl for TIOCNOTTY on controlling terminal failed (errno = " << errno << ")" << endl;
176 } else { 176 } else {
177 DEBUG << "ioctl for TIOCNOTTY succeeded" << endl; 177 DEBUG << "ioctl for TIOCNOTTY on controlling terminal succeeded" << endl;
178 } 178 return;
179 return; 179 }
180 } 180 }
181 181
182 #endif 182 #endif
183 } 183 }
184 184