comparison scpmisc.c @ 303:b27fcd28f9dc ucc-axis-hack

printf not fprintf for scp stuff
author Matt Johnston <matt@ucc.asn.au>
date Sat, 25 Mar 2006 13:35:44 +0000
parents 973fccb59ea4
children
comparison
equal deleted inserted replaced
302:973fccb59ea4 303:b27fcd28f9dc
218 218
219 void fatal(char* fmt,...) 219 void fatal(char* fmt,...)
220 { 220 {
221 va_list args; 221 va_list args;
222 va_start(args, fmt); 222 va_start(args, fmt);
223 vfprintf(stderr, fmt, args); 223 vprintf( fmt, args);
224 va_end(args); 224 va_end(args);
225 exit(255); 225 exit(255);
226 } 226 }
227 227
228 void 228 void
229 sanitise_stdfd(void) 229 sanitise_stdfd(void)
230 { 230 {
231 int nullfd, dupfd; 231 int nullfd, dupfd;
232 232
233 if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { 233 if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
234 fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno)); 234 printf( "Couldn't open /dev/null: %s", strerror(errno));
235 exit(1); 235 exit(1);
236 } 236 }
237 while (++dupfd <= 2) { 237 while (++dupfd <= 2) {
238 /* Only clobber closed fds */ 238 /* Only clobber closed fds */
239 if (fcntl(dupfd, F_GETFL, 0) >= 0) 239 if (fcntl(dupfd, F_GETFL, 0) >= 0)
240 continue; 240 continue;
241 if (dup2(nullfd, dupfd) == -1) { 241 if (dup2(nullfd, dupfd) == -1) {
242 fprintf(stderr, "dup2: %s", strerror(errno)); 242 printf( "dup2: %s", strerror(errno));
243 exit(1); 243 exit(1);
244 } 244 }
245 } 245 }
246 if (nullfd > 2) 246 if (nullfd > 2)
247 close(nullfd); 247 close(nullfd);