1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Add protocol/common files ;)

This commit is contained in:
Jonas Fonseca 2006-01-16 23:42:17 +01:00 committed by Jonas Fonseca
parent 0955086a6f
commit bb12fbca37
2 changed files with 44 additions and 0 deletions

37
src/protocol/common.c Normal file
View File

@ -0,0 +1,37 @@
/* Shared protocol functions */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> /* FreeBSD needs this before resource.h */
#endif
#include <sys/types.h> /* FreeBSD needs this before resource.h */
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "elinks.h"
#include "protocol/common.h"
/* Close all non-terminal file descriptors. */
void
close_all_non_term_fd(void)
{
int n;
int max = 1024;
#ifdef RLIMIT_NOFILE
struct rlimit lim;
if (!getrlimit(RLIMIT_NOFILE, &lim))
max = lim.rlim_max;
#endif
for (n = 3; n < max; n++)
close(n);
}

7
src/protocol/common.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef EL__PROTOCOL_COMMON_H
#define EL__PROTOCOL_COMMON_H
/* Close all non-terminal file descriptors. */
void close_all_non_term_fd(void);
#endif