1: #ifndef lint
   2: static char *rcsid_xinit_c = "$Header: xinit.c,v 10.3 86/02/01 16:24:54 tony Rel $";
   3: #endif	lint
   4: #include <X/mit-copyright.h>
   5: 
   6: /* Copyright    Massachusetts Institute of Technology    1986	*/
   7: 
   8: #include <stdio.h>
   9: #include <ctype.h>
  10: #include <signal.h>
  11: 
  12: #define default_server "X"
  13: #define default_display "0"
  14: char *default_client[] = {"xterm", "=+1+1", "-n", "login",
  15: #ifdef sun
  16:               "-C",
  17: #endif
  18:               "unix:0", NULL};
  19: char *server[100];
  20: char *client[100];
  21: 
  22: main(argc, argv)
  23:     int argc;
  24:     register char **argv;
  25: {
  26:     register char **sptr = server;
  27:     register char **cptr = client;
  28:     register char **ptr;
  29:     int serverpid, clientpid, pid;
  30: 
  31:     argv++;
  32:     argc--;
  33:     if (argc == 0 || (**argv != '/' && !isalpha(**argv)))
  34:         for (ptr = default_client; *ptr; )
  35:         *cptr++ = *ptr++;
  36:     while (argc && strcmp(*argv, "--")) {
  37:         *cptr++ = *argv++;
  38:         argc--;
  39:     }
  40:     *cptr = NULL;
  41:     if (argc) {
  42:         argv++;
  43:         argc--;
  44:     }
  45:     if (argc == 0 || (**argv != '/' && !isalpha(**argv))) {
  46:         *sptr++ = default_server;
  47:         if (argc == 0 || !isdigit(**argv))
  48:         *sptr++ = default_display;
  49:     }
  50:     while (--argc >= 0)
  51:         *sptr++ = *argv++;
  52:     *sptr++ = "0";
  53:     *sptr = NULL;
  54:     if ((serverpid = fork()) == 0) {
  55:         close(0);
  56:         close(1);
  57:         execvp(server[0], server);
  58:         perror(server[0]);
  59:         exit(1);
  60:     }
  61:     if (serverpid < 0) {
  62:         perror(server[0]);
  63:         exit(1);
  64:     }
  65:     sleep(5);
  66:     if ((clientpid = fork()) == 0) {
  67:         execvp(client[0], client);
  68:         perror(client[0]);
  69:         exit(1);
  70:     }
  71:     if (clientpid < 0) {
  72:         kill(serverpid, SIGKILL);
  73:         perror(client[0]);
  74:         exit(1);
  75:     }
  76:     while (((pid = wait(NULL)) != clientpid) && (pid != serverpid)) ;
  77:     kill(clientpid, SIGKILL);
  78:     if (!kill(serverpid, SIGHUP)) {
  79:         sleep(1);
  80:         kill(serverpid, SIGKILL);
  81:     }
  82: }

Defined functions

main defined in line 22; never used

Defined variables

client defined in line 20; used 5 times
default_client defined in line 14; used 1 times
  • in line 34
rcsid_xinit_c defined in line 2; never used
server defined in line 19; used 5 times

Defined macros

default_display defined in line 13; used 1 times
  • in line 48
default_server defined in line 12; used 1 times
  • in line 46
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1137
Valid CSS Valid XHTML 1.0 Strict