|
Lines 434-439
Link Here
|
| 434 |
return 0; |
434 |
return 0; |
| 435 |
} |
435 |
} |
| 436 |
|
436 |
|
|
|
437 |
static void |
| 438 |
sigwinchHandler(int sig) { |
| 439 |
sigwinch_queued = 1; |
| 440 |
} |
| 441 |
|
| 442 |
static void |
| 443 |
sigchldHandler(int sig) |
| 444 |
{ |
| 445 |
sigchld_queued = 1; |
| 446 |
} |
| 437 |
|
447 |
|
| 438 |
static int |
448 |
static int |
| 439 |
condom(int argc, char **argv) |
449 |
condom(int argc, char **argv) |
|
Lines 444-450
Link Here
|
| 444 |
char *path; |
454 |
char *path; |
| 445 |
char **child_argv; |
455 |
char **child_argv; |
| 446 |
int rc; |
456 |
int rc; |
| 447 |
|
457 |
int val; |
|
|
458 |
|
| 448 |
rc = parseArgs(argc, argv, child_argv0, |
459 |
rc = parseArgs(argc, argv, child_argv0, |
| 449 |
&path, &child_argv); |
460 |
&path, &child_argv); |
| 450 |
if(rc < 0) |
461 |
if(rc < 0) |
|
Lines 461-466
Link Here
|
| 461 |
perror("Couldn't drop priviledges"); |
472 |
perror("Couldn't drop priviledges"); |
| 462 |
exit(1); |
473 |
exit(1); |
| 463 |
} |
474 |
} |
|
|
475 |
|
| 476 |
if(verbose) { |
| 477 |
reportIso2022(outputState); |
| 478 |
} |
| 479 |
|
| 480 |
#ifdef SIGWINCH |
| 481 |
installHandler(SIGWINCH, sigwinchHandler); |
| 482 |
#endif |
| 483 |
installHandler(SIGCHLD, sigchldHandler); |
| 484 |
|
| 485 |
rc = copyTermios(0, pty); |
| 486 |
if(rc < 0) |
| 487 |
FatalError("Couldn't copy terminal settings\n"); |
| 488 |
|
| 489 |
rc = setRawTermios(); |
| 490 |
if(rc < 0) |
| 491 |
FatalError("Couldn't set terminal to raw\n"); |
| 492 |
|
| 493 |
val = fcntl(0, F_GETFL, 0); |
| 494 |
if(val >= 0) { |
| 495 |
fcntl(0, F_SETFL, val | O_NONBLOCK); |
| 496 |
} |
| 497 |
val = fcntl(pty, F_GETFL, 0); |
| 498 |
if(val >= 0) { |
| 499 |
fcntl(pty, F_SETFL, val | O_NONBLOCK); |
| 500 |
} |
| 501 |
|
| 502 |
setWindowSize(0, pty); |
| 464 |
|
503 |
|
| 465 |
pid = fork(); |
504 |
pid = fork(); |
| 466 |
if(pid < 0) { |
505 |
if(pid < 0) { |
|
Lines 517-569
Link Here
|
| 517 |
exit(1); |
556 |
exit(1); |
| 518 |
} |
557 |
} |
| 519 |
|
558 |
|
| 520 |
static void |
|
|
| 521 |
sigwinchHandler(int sig) { |
| 522 |
sigwinch_queued = 1; |
| 523 |
} |
| 524 |
|
| 525 |
static void |
| 526 |
sigchldHandler(int sig) |
| 527 |
{ |
| 528 |
sigchld_queued = 1; |
| 529 |
} |
| 530 |
|
| 531 |
void |
559 |
void |
| 532 |
parent(int pid, int pty) |
560 |
parent(int pid, int pty) |
| 533 |
{ |
561 |
{ |
| 534 |
unsigned char buf[BUFFER_SIZE]; |
562 |
unsigned char buf[BUFFER_SIZE]; |
| 535 |
int i; |
563 |
int i; |
| 536 |
int val; |
|
|
| 537 |
int rc; |
564 |
int rc; |
| 538 |
|
565 |
|
| 539 |
if(verbose) { |
|
|
| 540 |
reportIso2022(outputState); |
| 541 |
} |
| 542 |
|
| 543 |
#ifdef SIGWINCH |
| 544 |
installHandler(SIGWINCH, sigwinchHandler); |
| 545 |
#endif |
| 546 |
installHandler(SIGCHLD, sigchldHandler); |
| 547 |
|
| 548 |
rc = copyTermios(0, pty); |
| 549 |
if(rc < 0) |
| 550 |
FatalError("Couldn't copy terminal settings\n"); |
| 551 |
|
| 552 |
rc = setRawTermios(); |
| 553 |
if(rc < 0) |
| 554 |
FatalError("Couldn't set terminal to raw\n"); |
| 555 |
|
| 556 |
val = fcntl(0, F_GETFL, 0); |
| 557 |
if(val >= 0) { |
| 558 |
fcntl(0, F_SETFL, val | O_NONBLOCK); |
| 559 |
} |
| 560 |
val = fcntl(pty, F_GETFL, 0); |
| 561 |
if(val >= 0) { |
| 562 |
fcntl(pty, F_SETFL, val | O_NONBLOCK); |
| 563 |
} |
| 564 |
|
| 565 |
setWindowSize(0, pty); |
| 566 |
|
| 567 |
for(;;) { |
566 |
for(;;) { |
| 568 |
rc = waitForInput(0, pty); |
567 |
rc = waitForInput(0, pty); |
| 569 |
|
568 |
|