Ignore:
Timestamp:
Oct 10, 2008, 12:24:51 AM (14 years ago)
Author:
Pascal Terjan
Message:
  • Cleanup my term after a grab
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/grab.c

    r2785 r2906  
    4040    char fdstr[1024];
    4141    struct mytrace *parent, *child;
    42     int i, fd = 0, mode, ret;
     42    int i, fd = 0, ret;
    4343    char to_open[3];
     44    int mode[3];
    4445    struct stat stat_buf;
     46    struct termios tos;
    4547
    4648    debug("pty is %s", ptyname);
     
    5456
    5557    child = mytrace_fork(parent);
    56     mytrace_write(parent, 1, "\x1b]0;\x07", 5);
    57     mytrace_write(parent, 1, "\x1b[1000l", 7);
    58     mytrace_write(parent, 1, "\x1b[?12l\x1b[?25h", 12);
     58    mytrace_write(parent, 1, "\x1b[H\x1b[2J", 7);
    5959    mytrace_write(parent, 1, "\n[Process stolen by neercs]\n", 28);
    60     /* FIXME Reset the term */
     60    mytrace_tcgets(parent, 1, &tos);
     61    tos.c_lflag |= ICANON|ECHO;
     62    mytrace_tcsets(parent, 1, &tos);
    6163    mytrace_close(parent, 1);
    62 
    6364    mytrace_exit(parent, 0);
    6465    mytrace_detach(parent);
     
    7273        lstat(fdstr, &stat_buf);
    7374        if((stat_buf.st_mode & S_IRUSR) && (stat_buf.st_mode & S_IWUSR))
    74             mode = O_RDWR;
     75            mode[i] = O_RDWR;
    7576        else if(stat_buf.st_mode & S_IWUSR)
    76             mode = O_WRONLY;
     77            mode[i] = O_WRONLY;
    7778        else
    78             mode = O_RDONLY;
     79            mode[i] = O_RDONLY;
    7980
    8081        if(stat(fdstr, &stat_buf) < 0)
     
    128129        if(!to_open[i])
    129130            continue;
    130         fd = mytrace_open(child, ptyname, mode);
     131        fd = mytrace_open(child, ptyname, mode[i]);
    131132        if(fd < 0)
    132133        {
Note: See TracChangeset for help on using the changeset viewer.