Changeset 3891 for neercs/trunk


Ignore:
Timestamp:
Nov 6, 2009, 6:46:05 PM (10 years ago)
Author:
Pascal Terjan
Message:
  • Store real pid in screen struct (even if not used) and properly set control terminal (even if not needed)
Location:
neercs/trunk/src
Files:
6 edited

Legend:

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

    r3875 r3891  
    3939#include "mytrace.h"
    4040
    41 int grab_process(long pid, char *ptyname, int ptyfd)
     41int grab_process(long pid, char *ptyname, int ptyfd, int *newpid)
    4242{
    4343#if defined HAVE_LINUX_KDEV_T_H
     
    117117    }
    118118
    119     if(parent)
    120     {
    121         ret = mytrace_exec(parent, "/usr/bin/reset");
    122         if(ret < 0)
    123             mytrace_exit(parent, 0);
    124         mytrace_detach(parent);
    125         waitpid(pid, NULL, 0); /* Wait for reset to finish before displaying */
    126         mytrace_write(child, 2, "\x1b[H\x1b[2J", 7);
    127         mytrace_write(child, 2, "\n[Process stolen by neercs]\r\n\n", 30);
    128     }
     119    ret = mytrace_exec(parent, "/usr/bin/reset");
     120    if(ret < 0)
     121        mytrace_exit(parent, 0);
     122    mytrace_detach(parent);
     123    waitpid(pid, NULL, 0); /* Wait for reset to finish before displaying */
     124    mytrace_write(child, 2, "\x1b[H\x1b[2J", 7);
     125    mytrace_write(child, 2, "\n[Process stolen by neercs]\r\n\n", 30);
     126
     127    pid = mytrace_getpid(child);
     128    *newpid = pid;
    129129
    130130    /* Set the process's session ID */
     
    173173            continue;
    174174        }
     175       
     176        /* FIXME Only needed once */
     177        mytrace_sctty(child, fd);
     178
    175179        if(validtos)
    176180        {
  • neercs/trunk/src/mytrace.c

    r3873 r3891  
    474474    errno = err;
    475475    return ret;
     476#else
     477    errno = ENOSYS;
     478    return -1;
     479#endif
     480}
     481
     482int mytrace_sctty(struct mytrace *t, int fd)
     483{
     484#if defined USE_GRAB
     485    ptrace(PTRACE_SETOPTIONS, t->pid, NULL, PTRACE_O_TRACEEXIT);
     486    return remote_syscall(t, MYCALL_IOCTL, fd, TIOCSCTTY, 0);
    476487#else
    477488    errno = ENOSYS;
  • neercs/trunk/src/mytrace.h

    r3873 r3891  
    3333int mytrace_tcgets(struct mytrace *t, int fd, struct termios *tos);
    3434int mytrace_tcsets(struct mytrace *t, int fd, struct termios *tos);
     35int mytrace_sctty(struct mytrace *t, int fd);
  • neercs/trunk/src/neercs.h

    r3876 r3891  
    227227
    228228int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
    229 int create_pty_grab(long pid, unsigned int w, unsigned int h);
    230 int grab_process(long pid, char *ptyname, int ptyfd);
     229int create_pty_grab(long pid, unsigned int w, unsigned int h, int *cpid);
     230int grab_process(long pid, char *ptyname, int ptyfd, int *newpid);
    231231long select_process(struct screen_list* screen_list);
    232232
  • neercs/trunk/src/screens.c

    r3551 r3891  
    4545    s->h = h+1;
    4646    s->bell = 0;
    47     s->pid = pid;
    48 
    49     s->fd = create_pty_grab(pid, w, h);
     47
     48    s->fd = create_pty_grab(pid, w, h, &s->pid);
    5049
    5150    if(s->fd < 0)
  • neercs/trunk/src/term.c

    r3461 r3891  
    831831}
    832832
    833 int create_pty_grab(long pid, unsigned int w, unsigned int h)
     833int create_pty_grab(long pid, unsigned int w, unsigned int h, int *newpid)
    834834{
    835835    int fdm, fds;
     
    844844
    845845    set_tty_size(0, w, h);
    846     grab_process(pid, ptsname(fdm), fds);
     846    grab_process(pid, ptsname(fdm), fds, newpid);
    847847
    848848    fcntl(fdm, F_SETFL, O_NDELAY);
Note: See TracChangeset for help on using the changeset viewer.