*** server.c.orig Sun Mar 26 20:33:31 1995 --- server.c Wed Oct 9 21:29:25 1996 *************** *** 48,53 **** --- 48,56 ---- #include /* For getpwuid(). */ #include #include + #ifdef __FreeBSD__ + #include + #endif #include "youbin.h" #include "server.h" *************** *** 154,159 **** --- 157,171 ---- dummy.tv_sec = (long)(UNIT_TIME * 10); dummy.tv_usec = 0L; + /*Go to background. This part was modified locally by Masafumi NAKANE + , and is used only on FreeBSD./* + #ifdef __FreeBSD__ + if (daemon(1, 1) == -1) { + perror("daemon"); + kill(getpid(), SIGTERM); + } + #endif + /* Dive into main loop. Don't use setjmp() and longjmp(), because list maintenance routines are in critical section. */ alarm(UNIT_TIME); *************** *** 244,250 **** char buff[MESS_LEN + 1]; int len, flen = sizeof(ca); ! if ((len = recvfrom(fid, buff, MESS_LEN, 0, &ca, &flen)) < 0) { if (errno != EINTR) { warn_log("Error in receiving packet\n"); } --- 256,262 ---- char buff[MESS_LEN + 1]; int len, flen = sizeof(ca); ! if ((len = recvfrom(fid, buff, MESS_LEN, 0, (struct sockaddr *)&ca, &flen)) < 0) { if (errno != EINTR) { warn_log("Error in receiving packet\n"); } *************** *** 543,549 **** saddr->sin_family = hp->h_addrtype; saddr->sin_addr.s_addr = htonl(INADDR_ANY); saddr->sin_port = sp->s_port; ! if (bind(id, saddr, sizeof(*saddr)) < 0) { sys_error_log("bind"); exit(EXIT_FAILURE); } --- 555,561 ---- saddr->sin_family = hp->h_addrtype; saddr->sin_addr.s_addr = htonl(INADDR_ANY); saddr->sin_port = sp->s_port; ! if (bind(id, (struct sockaddr *)saddr, sizeof(*saddr)) < 0) { sys_error_log("bind"); exit(EXIT_FAILURE); } *************** *** 586,592 **** debug_log("Send: %s [%ld]: \"%.*s\"\n", ((sp == CA_ADDR) ? "" : sp->parent->name), (long)sp, MAX_DEBUG_COLUMN, mess); ! if (sendto(sockid, mess, strlen(mess), 0, saddr, sizeof(*saddr)) < 0) { warn_log("Error in sending packet: %s\n", mess); } } --- 598,604 ---- debug_log("Send: %s [%ld]: \"%.*s\"\n", ((sp == CA_ADDR) ? "" : sp->parent->name), (long)sp, MAX_DEBUG_COLUMN, mess); ! if (sendto(sockid, mess, strlen(mess), 0, (struct sockaddr *)saddr, sizeof(*saddr)) < 0) { warn_log("Error in sending packet: %s\n", mess); } }