/* Allow to share a single invocation of a program to multiple sessions */ #include #include #include /* needed for select */ #include /* needed for stderr */ #include /* needed for open */ #include /* needed for I_PUSH */ #include #include /* UNIX socket IPC */ #include /* error codes form system calls */ #include /* needed for "raw" input mode */ #include /* needed for child process monitoring */ #include #include #define SESSDIR "/usr/tmp/session/" static int window_stdin; main (int argc, char **argv) { char name[2048], command[2048]; int i; if (argc < 2 || strcmp(argv[1],"-n") == 0 && argc < 4) { fputs ("usage: session [-n name] command [args ...]\n",stderr); exit(1); } if (strcmp(argv[1],"-n") == 0) { strcpy (name,argv[2]); /* rebuild command line broken up into argv[] array */ strcpy (command,""); for (i=3; i=20) { fputs ("< 20 connections\n",stderr); continue; } connection[i] = accept (sock,&addr,&addrlen); if (connection[i] < 0) { perror ("accept"); exit(1); } } for (i=0;i= 0) win.ws_row = rows; if (cols >= 0) win.ws_col = cols; if (ioctl (ptty, TIOCSWINSZ, (char *) &win)) { perror("ioctl TIOCSWINSZ"); exit (1); } }