Commit 28f917c6 authored by Jonathon Duerig's avatar Jonathon Duerig

Minor tweaks to the declarations used in argument processing. magent now...

Minor tweaks to the declarations used in argument processing. magent now backgrounds itself at the end of initialization. It stays in the same directory and keeps its standard files open.
parent 63cfa942
......@@ -3,7 +3,10 @@
#ifndef LIB_H_PELAB_2
#define LIB_H_PELAB_2
extern "C"
{
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
......@@ -28,6 +31,9 @@
#include <netinet/udp.h>
#include <netinet/tcp.h>
extern char * optarg;
}
#include <utility>
#include <list>
#include <map>
......@@ -120,17 +126,7 @@ struct Order
return !(*this == right);
}
};
/*
struct PlanetOrder
{
unsigned long localPort;
bool operator<(PlanetOrder const & right) const
{
return localPort < right.localPort;
}
};
*/
struct WriteResult
{
bool isConnected;
......
......@@ -16,12 +16,6 @@
using namespace std;
// For option processing
extern "C" {
#include <getopt.h>
#include <stdio.h>
};
namespace global
{
int connectionModelArg = 0;
......@@ -57,6 +51,12 @@ int main(int argc, char * argv[])
{
processArgs(argc, argv);
init();
// Run with no change in directory, and no closing of standard files.
int error = daemon(1, 1);
if (error == -1)
{
logWrite(ERROR, "Daemonization failed: %s", strerror(errno));
}
mainLoop();
return 0;
}
......@@ -66,7 +66,7 @@ void usageMessage(char *progname) {
cerr << " --connectionmodel=<null|kerneltcp> " << endl;
cerr << " --peerserverport=<int> " << endl;
cerr << " --monitorserverport=<int> " << endl;
cerr << " --internface=<iface> " << endl;
cerr << " --interface=<iface> " << endl;
logWrite(ERROR, "Bad command line argument", global::connectionModelArg);
}
......@@ -78,10 +78,6 @@ void processArgs(int argc, char * argv[])
global::monitorServerPort = 4200;
global::interface = "vnet";
// From the getopt library
// XXX - We might need to wrap this in 'extern "C"'
extern char *optarg;
static struct option longOptions[] = {
// If you modify this, make sure to modify the shortOptions string below
// too.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment