Changeset 2371 for neercs


Ignore:
Timestamp:
Jun 13, 2008, 4:44:11 PM (12 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added ctrl-a-k to close a window and associated process (temporary code) (et pterjan a un sale PS1)
Location:
neercs/trunk/src
Files:
3 edited

Legend:

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

    r2367 r2371  
    201201    cucul_printf(cv, x, y++, "c:\t Create new window");
    202202    cucul_printf(cv, x, y++, "m:\t Thumbnails");
     203    cucul_printf(cv, x, y++, "k:\t Close window and kill associated process");
    203204    cucul_printf(cv, x, y++, "h:\t This help");
    204205}
  • neercs/trunk/src/main.c

    r2370 r2371  
    2121#include <unistd.h>
    2222#include <fcntl.h>
     23#include <sys/types.h>
     24#include <signal.h>
    2325#include <sys/ioctl.h>
     26#include <sys/types.h>
     27#include <sys/wait.h>
     28
    2429#if defined HAVE_PTY_H
    2530#   include <pty.h>  /* for openpty and forkpty */
     
    3641#define YTAB 3
    3742
    38 static int create_pty(char *cmd, unsigned int w, unsigned int h);
     43static int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
    3944
    4045int main(int argc, char **argv)
     
    178183                        screen_list->screen[i]->fd = -1;
    179184                        destroy_screen(screen_list->screen[i]);
    180                         remove_screen(screen_list, i);
     185                        remove_screen(screen_list, i, 0);
    181186                        refresh = 1;
    182187                    }
     
    248253                                            screen_list->wm_type=0:
    249254                                            screen_list->wm_type+1);
     255                    refresh = 1;
     256                    break;
     257                case 0x0b: //CACA_KEY_CTRL_K:
     258                    remove_screen(screen_list, pty, 1);
     259                    pty = prevpty;
    250260                    refresh = 1;
    251261                    break;
     
    320330            }
    321331
    322 
    323332            cucul_blit(cv,
    324333                       screen_list->screen[pty]->x,
    325334                       screen_list->screen[pty]->y,
    326                    screen_list->screen[pty]->cv, NULL);
     335                       screen_list->screen[pty]->cv, NULL);
    327336            if(screen_list->screen[pty]->bell)
    328337            {
     
    385394}
    386395
    387 static int create_pty(char *cmd, unsigned int w, unsigned int h)
     396static int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid)
    388397{
    389398    char **argv;
     
    410419    }
    411420
     421    *cpid = pid;
     422
    412423    fcntl(fd, F_SETFL, O_NDELAY);
    413424    return fd;
     
    446457    s->w = w+1;
    447458    s->h = h+1;
    448     s->fd = create_pty(command, w, h);
     459    s->fd = create_pty(command, w, h, &s->pid);
    449460    s->bell = 0;
    450461
     
    482493}
    483494
    484 int remove_screen(struct screen_list *list, int n)
     495int remove_screen(struct screen_list *list, int n, int please_kill)
    485496{
    486497    if(n>list->count) return -1;
     498
     499    if(please_kill)
     500    {
     501        int status = 0;
     502        int ret = 0;
     503        /* FIXME */
     504        close(list->screen[n]->fd);
     505        kill(list->screen[n]->pid, SIGINT);
     506        ret = waitpid(list->screen[n]->pid, &status, WNOHANG|WUNTRACED|WCONTINUED);
     507        if(!ret)
     508            kill(list->screen[n]->pid, SIGQUIT);
     509        ret = waitpid(list->screen[n]->pid, &status, WNOHANG|WUNTRACED|WCONTINUED);
     510        if(!ret)
     511            kill(list->screen[n]->pid, SIGABRT);
     512        ret = waitpid(list->screen[n]->pid, &status, WNOHANG|WUNTRACED|WCONTINUED);
     513        if(!ret)
     514            kill(list->screen[n]->pid, SIGKILL);
     515
     516    }
    487517
    488518    memmove(&list->screen[n],
  • neercs/trunk/src/neercs.h

    r2368 r2371  
    4343    long int total;
    4444    int bell;
     45    int pid;
    4546
    4647    int x, y;
     
    6768int destroy_screen(struct screen *s);
    6869int add_screen(struct screen_list *list, struct screen *s);
    69 int remove_screen(struct screen_list *list, int n);
     70int remove_screen(struct screen_list *list, int n, int please_kill);
    7071void resize_screen(struct screen *s, int z, int h);
    7172
Note: See TracChangeset for help on using the changeset viewer.