Changeset 2429 for neercs


Ignore:
Timestamp:
Jun 15, 2008, 7:17:36 PM (12 years ago)
Author:
Pascal Terjan
Message:
  • Remove one of the reads of /proc
Location:
neercs/trunk/src
Files:
3 edited

Legend:

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

    r2428 r2429  
    256256}
    257257
    258 int grab_process(pid_t pid, int ptyfd)
     258int grab_process(pid_t pid, char *ptyname, int ptyfd)
    259259{
    260260    struct termios t;
    261261    int i, fd = 0, mode, ret;
    262     char tty[1024];
    263262    char fdstr[1024];
    264263    struct stat stat_buf;
    265264
    266     snprintf(fdstr, sizeof(fdstr), "/proc/%d/fd/%d", getpid(), ptyfd);
    267     if ((i = readlink(fdstr, tty, sizeof(tty)-1)) == -1) {
    268         fprintf(stderr, "readlink failed\n");
    269         return -1;
    270     }
    271     tty[i] = 0;
    272     debug("Our pty is %s", tty);
     265    debug("pty is %s", ptyname);
    273266
    274267    if(ptrace(PTRACE_ATTACH, pid, 0, 0) < 0)
     
    304297            fprintf(stderr, "do_close %s\n", strerror(ret));
    305298        }
    306         if((ret = do_open(pid, tty, mode, &fd)))
     299        if((ret = do_open(pid, ptyname, mode, &fd)))
    307300        {
    308301            fprintf(stderr, "do_open %s\n", strerror(ret));
  • neercs/trunk/src/neercs.h

    r2426 r2429  
    7777int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
    7878int create_pty_grab(pid_t pid, unsigned int w, unsigned int h);
    79 int grab_process(pid_t pid, int ptyfd);
     79int grab_process(pid_t pid, char *ptyname, int ptyfd);
    8080
    8181long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
  • neercs/trunk/src/term.c

    r2426 r2429  
    1515#include "config.h"
    1616
     17#define _XOPEN_SOURCE
    1718#include <stdlib.h>
    1819#include <stdio.h>
     
    590591
    591592    set_tty_size(0, w, h);
    592     grab_process(pid, fds);
     593    grab_process(pid, ptsname(fdm), fds);
    593594
    594595    fcntl(fdm, F_SETFL, O_NDELAY);
Note: See TracChangeset for help on using the changeset viewer.