Subversion Repositories heating

Rev

Rev 9 | Rev 48 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9 Rev 18
Line 37... Line 37...
37
#include <netinet/in.h>
37
#include <netinet/in.h>
38
#include <sys/ioctl.h>
38
#include <sys/ioctl.h>
39
#include <sys/param.h>
39
#include <sys/param.h>
40
#include <pwd.h>
40
#include <pwd.h>
41
#include <grp.h>
41
#include <grp.h>
-
 
42
#include <sys/resource.h>
42
#include "config.h"
43
#include "config.h"
43
#include "heating.h"
44
#include "heating.h"
44
 
45
 
45
struct SOCKETS
46
struct SOCKETS
46
{
47
{
Line 65... Line 66...
65
heating *heat;
66
heating *heat;
66
struct SOCKETS soc;				// The network sockets to be passed to a thread
67
struct SOCKETS soc;				// The network sockets to be passed to a thread
67
 
68
 
68
int main(int argc, char **argv) 
69
int main(int argc, char **argv) 
69
{
70
{
-
 
71
struct rlimit core_limits;
-
 
72
 
70
	heat = nullptr;
73
	heat = nullptr;
71
	// First read config file and check if it was ok
74
	// First read config file and check if it was ok
72
	config *cfg = new config();
75
	config *cfg = new config();
73
	
76
	
74
	if (!cfg->is_initialized())
77
	if (!cfg->is_initialized())
Line 80... Line 83...
80
	
83
	
81
	CONFIGURE configs = cfg->getConfig();
84
	CONFIGURE configs = cfg->getConfig();
82
	// Daemonize and run in background
85
	// Daemonize and run in background
83
	daemon_start(0);
86
	daemon_start(0);
84
	changeToUser(configs.user, configs.group);
87
	changeToUser(configs.user, configs.group);
-
 
88
	// core dumps may be disallowed by parent of this process; change that
-
 
89
	if (Configure.debug)
-
 
90
	{
-
 
91
		core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
-
 
92
		setrlimit(RLIMIT_CORE, &core_limits);
-
 
93
	}
85
	// We no longer need the configuration data here, so we remove them.
94
	// We no longer need the configuration data here, so we remove them.
86
	delete (cfg);
95
	delete (cfg);
87
	// Now start our Thread
96
	// Now start our Thread
88
	if (pthread_create(&pthr_pars, NULL, pthr_parser, (void *)0) != 0)
97
	if (pthread_create(&pthr_pars, NULL, pthr_parser, (void *)0) != 0)
89
	{
98
	{