summaryrefslogtreecommitdiff
path: root/mail/youbin/files/patch-ae
blob: 6f9343aad4fcc07e7d680643bd18f4dc0468c72d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
*** server.c.orig	Sun Mar 26 20:33:31 1995
--- server.c	Wed Oct  9 21:29:25 1996
***************
*** 48,53 ****
--- 48,56 ----
  #include <pwd.h>                /* For getpwuid(). */
  #include <signal.h>
  #include <stdio.h>
+ #ifdef __FreeBSD__
+ #include <stdlib.h>
+ #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
+         <max@wide.ad.jp>, 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);
      }
  }