- Timestamp:
- Jun 13, 2008, 4:44:11 PM (13 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/effects.c
r2367 r2371 201 201 cucul_printf(cv, x, y++, "c:\t Create new window"); 202 202 cucul_printf(cv, x, y++, "m:\t Thumbnails"); 203 cucul_printf(cv, x, y++, "k:\t Close window and kill associated process"); 203 204 cucul_printf(cv, x, y++, "h:\t This help"); 204 205 } -
neercs/trunk/src/main.c
r2370 r2371 21 21 #include <unistd.h> 22 22 #include <fcntl.h> 23 #include <sys/types.h> 24 #include <signal.h> 23 25 #include <sys/ioctl.h> 26 #include <sys/types.h> 27 #include <sys/wait.h> 28 24 29 #if defined HAVE_PTY_H 25 30 # include <pty.h> /* for openpty and forkpty */ … … 36 41 #define YTAB 3 37 42 38 static int create_pty(char *cmd, unsigned int w, unsigned int h );43 static int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid); 39 44 40 45 int main(int argc, char **argv) … … 178 183 screen_list->screen[i]->fd = -1; 179 184 destroy_screen(screen_list->screen[i]); 180 remove_screen(screen_list, i );185 remove_screen(screen_list, i, 0); 181 186 refresh = 1; 182 187 } … … 248 253 screen_list->wm_type=0: 249 254 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; 250 260 refresh = 1; 251 261 break; … … 320 330 } 321 331 322 323 332 cucul_blit(cv, 324 333 screen_list->screen[pty]->x, 325 334 screen_list->screen[pty]->y, 326 screen_list->screen[pty]->cv, NULL);335 screen_list->screen[pty]->cv, NULL); 327 336 if(screen_list->screen[pty]->bell) 328 337 { … … 385 394 } 386 395 387 static int create_pty(char *cmd, unsigned int w, unsigned int h )396 static int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid) 388 397 { 389 398 char **argv; … … 410 419 } 411 420 421 *cpid = pid; 422 412 423 fcntl(fd, F_SETFL, O_NDELAY); 413 424 return fd; … … 446 457 s->w = w+1; 447 458 s->h = h+1; 448 s->fd = create_pty(command, w, h );459 s->fd = create_pty(command, w, h, &s->pid); 449 460 s->bell = 0; 450 461 … … 482 493 } 483 494 484 int remove_screen(struct screen_list *list, int n )495 int remove_screen(struct screen_list *list, int n, int please_kill) 485 496 { 486 497 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 } 487 517 488 518 memmove(&list->screen[n], -
neercs/trunk/src/neercs.h
r2368 r2371 43 43 long int total; 44 44 int bell; 45 int pid; 45 46 46 47 int x, y; … … 67 68 int destroy_screen(struct screen *s); 68 69 int add_screen(struct screen_list *list, struct screen *s); 69 int remove_screen(struct screen_list *list, int n );70 int remove_screen(struct screen_list *list, int n, int please_kill); 70 71 void resize_screen(struct screen *s, int z, int h); 71 72
Note: See TracChangeset
for help on using the changeset viewer.