comparison lib-src/gnuserv.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children de805c49cfc1
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
71 #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */ 71 #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
72 72
73 #ifdef SYSV_IPC 73 #ifdef SYSV_IPC
74 74
75 int ipc_qid = 0; /* ipc message queue id */ 75 int ipc_qid = 0; /* ipc message queue id */
76 int ipc_wpid = 0; /* watchdog task pid */ 76 pid_t ipc_wpid = 0; /* watchdog task pid */
77 77
78 78
79 /* 79 /*
80 ipc_exit -- clean up the queue id and queue, then kill the watchdog task 80 ipc_exit -- clean up the queue id and queue, then kill the watchdog task
81 if it exists. exit with the given status. 81 if it exists. exit with the given status.
109 void 109 void
110 ipc_spawn_watchdog (void) 110 ipc_spawn_watchdog (void)
111 { 111 {
112 if ((ipc_wpid = fork ()) == 0) 112 if ((ipc_wpid = fork ()) == 0)
113 { /* child process */ 113 { /* child process */
114 int ppid = getppid (); /* parent's process id */ 114 pid_t ppid = getppid (); /* parent's process id */
115 115
116 setpgrp(); /* gnu kills process group on exit */ 116 setpgrp(); /* gnu kills process group on exit */
117 117
118 while (1) 118 while (1)
119 { 119 {
321 handle_response (void) 321 handle_response (void)
322 { 322 {
323 char buf[GSERV_BUFSZ+1]; 323 char buf[GSERV_BUFSZ+1];
324 int offset=0; 324 int offset=0;
325 int s; 325 int s;
326 int len; 326 int len = 0;
327 int result_len; 327 int result_len;
328 328
329 /* read in "n/m:" (n=client fd, m=message length) */ 329 /* read in "n/m:" (n=client fd, m=message length) */
330 while (offset < GSERV_BUFSZ && 330 while (offset < GSERV_BUFSZ &&
331 ((len = read(0,buf+offset,1)) > 0) && 331 ((len = read(0,buf+offset,1)) > 0) &&
697 size_t addrlen = sizeof(struct sockaddr_in); 697 size_t addrlen = sizeof(struct sockaddr_in);
698 struct sockaddr_in peer; /* for peer socket address */ 698 struct sockaddr_in peer; /* for peer socket address */
699 699
700 memset((char *)&peer,0,sizeof(struct sockaddr_in)); 700 memset((char *)&peer,0,sizeof(struct sockaddr_in));
701 701
702 if ((s = accept(ls,(struct sockaddr *)&peer, (void *) &addrlen)) == -1) 702 if ((s = accept(ls,(struct sockaddr *)&peer, &addrlen)) == -1)
703 { 703 {
704 perror(progname); 704 perror(progname);
705 fprintf(stderr,"%s: unable to accept\n",progname); 705 fprintf(stderr,"%s: unable to accept\n",progname);
706 exit(1); 706 exit(1);
707 } /* if */ 707 } /* if */
817 size_t len = sizeof(struct sockaddr_un); 817 size_t len = sizeof(struct sockaddr_un);
818 struct sockaddr_un server; /* for unix socket address */ 818 struct sockaddr_un server; /* for unix socket address */
819 819
820 server.sun_family = AF_UNIX; 820 server.sun_family = AF_UNIX;
821 821
822 if ((s = accept(ls,(struct sockaddr *)&server, (void *)&len)) < 0) 822 if ((s = accept(ls,(struct sockaddr *)&server, &len)) < 0)
823 { 823 {
824 perror(progname); 824 perror(progname);
825 fprintf(stderr,"%s: unable to accept\n",progname); 825 fprintf(stderr,"%s: unable to accept\n",progname);
826 } /* if */ 826 } /* if */
827 827