TCP-IP



         

UNIX - 2


40 int tselect( int, fd_set *, fd_set *, fd_set *);

41 unsigned int timeout( tofunc_t, void *, int );

42 void untimeout( unsigned int );

43 void init_smb( int ) ;

44 void *smballoc( void ) ;

45 void smbfree( void * ) ;

46 void smbsendf SOCKET, void * );

47 void *smbrecv( SOCKET ) ;

48 void set_address ( char *, char *, struct sockaddr_in *', char * ) ;

49 #endif /* _ETCP_H_ */

daemon

daemon, tcpmux, , BSD. SVR4 , 1.2.

1.2. daemon

daemon.

1 int daemon( int nocd, int noclose )

2 (

3 struct rlimit rlim;

4 pid_t pid;

5 int i;

6 mask( 0 ); /* . */

7 /* . */

8 if ( getrlimit( RLIMIT_NOFILE, &rlim ) < 0 )

9 error( 1, errno, "getrlimit failed" );

10 /* , ... */

11 pid = fork();

12 if ( pid < 0 )

13 return -1;

14 if ( pid != 0 )

15 exit( 0 ) ;

16 setsid();

17 /* ... , . */

18 signal( SIGHUP, SIG_IGN );

19 pid = fork(};

20 if ( pid < 0 )

21 return -1;

22 if ( pid != 0 )

23 exit( 0 );

24 * , */

25 if ( !nocd )

26 chdir( "/" ) ;

27 /*

28 * , .

29 * stdin, stdout stderr

30 * /dev/null.

31 */

32 if (!noclose }

33 {

34 #if 0 /* 1 . */

35 if ( rlim.rlim_max == RLIM_INFINITY )

3 rlim.rlim_max = 1024;