Changeset 4033 for neercs/trunk/src/server.c
- Timestamp:
- Nov 25, 2009, 12:47:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/server.c
r4026 r4033 212 212 213 213 214 214 215 215 screen_list->last_key_time = 0; 216 216 screen_list->attached = 0; … … 220 220 221 221 server_init(screen_list); 222 #ifdef USE_PYTHON 223 python_init(screen_list); 224 #endif 222 225 223 226 for (;;) … … 300 303 free_screen_list(screen_list); 301 304 305 #ifdef USE_PYTHON 306 python_close(screen_list); 307 #endif 308 302 309 exit(0); 303 310 } … … 453 460 if (screen_list->help) 454 461 { 455 return help_handle_key(screen_list, c);462 return help_handle_key(screen_list, c); 456 463 } 457 464 #ifdef USE_PYTHON 458 if(screen_list->python_command)459 { 460 return python_command_handle_key(screen_list, c);461 } 462 #endif 463 465 if (screen_list->python_command) 466 { 467 return python_command_handle_key(screen_list, c); 468 } 469 #endif 470 464 471 /* CTRL-A has been pressed before, handle this as a command, except that 465 CTRL-A a sends literal CTRL-A */472 CTRL-A a sends literal CTRL-A */ 466 473 if (screen_list->command && (c != 'a')) 467 474 { … … 527 534 } 528 535 536 537 int install_fds(struct screen_list *screen_list) 538 { 539 int fd; 540 close(0); 541 close(1); 542 close(2); 543 fd = open("/dev/null", O_RDWR, 0); 544 if (fd < 0) 545 { 546 perror("Failed to open /dev/null"); 547 return -2; 548 } 549 dup2(fd, 0); 550 #ifndef DEBUG 551 dup2(fd, 1); 552 dup2(fd, 2); 553 if (fd > 2) 554 close(fd); 555 #else 556 if (fd != 0) 557 close(fd); 558 screen_list->outfd = 559 open("/tmp/neercs-debug.txt", O_TRUNC | O_RDWR | O_CREAT, 560 S_IRUSR | S_IWUSR); 561 dup2(screen_list->outfd, 1); 562 dup2(screen_list->outfd, 2); 563 if (screen_list->outfd > 2) 564 close(screen_list->outfd); 565 #endif 566 return 0; 567 } 568 529 569 int start_server(struct screen_list *screen_list) 530 570 { … … 539 579 if (pid == 0) 540 580 { 541 int fd; 542 close(0); 543 close(1); 544 close(2); 545 fd = open("/dev/null", O_RDWR, 0); 546 if (fd < 0) 547 { 548 perror("Failed to open /dev/null"); 549 return -2; 550 } 551 dup2(fd, 0); 552 #ifndef DEBUG 553 dup2(fd, 1); 554 dup2(fd, 2); 555 if (fd > 2) 556 close(fd); 557 #else 558 if (fd != 0) 559 close(fd); 560 fd = open("/tmp/neercs-debug.txt", O_TRUNC | O_RDWR | O_CREAT, 561 S_IRUSR | S_IWUSR); 562 dup2(fd, 1); 563 dup2(fd, 2); 564 if (fd > 2) 565 close(fd); 566 #endif 581 int r = install_fds(screen_list); 582 if(r) return r; 567 583 setsid(); 568 584 … … 570 586 /* Never returns */ 571 587 } 572 588 573 589 return 0; 574 590 }
Note: See TracChangeset
for help on using the changeset viewer.