mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Silence kextload/kextunload output, error handling improvements.
This commit is contained in:
parent
b3491f9de1
commit
37341048a9
2 changed files with 12 additions and 1 deletions
9
main.cpp
9
main.cpp
|
@ -707,6 +707,7 @@ int main(int argc,char **argv)
|
||||||
RoutingTable *routingTable = ZTCreatePlatformRoutingTable;
|
RoutingTable *routingTable = ZTCreatePlatformRoutingTable;
|
||||||
|
|
||||||
node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset);
|
node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset);
|
||||||
|
|
||||||
switch(node->run()) {
|
switch(node->run()) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
case Node::NODE_RESTART_FOR_UPGRADE: {
|
case Node::NODE_RESTART_FOR_UPGRADE: {
|
||||||
|
@ -739,18 +740,24 @@ int main(int argc,char **argv)
|
||||||
fprintf(stderr,"%s: abnormal termination: unable to execute update at %s\n",argv[0],(upgPath) ? upgPath : "(unknown path)");
|
fprintf(stderr,"%s: abnormal termination: unable to execute update at %s\n",argv[0],(upgPath) ? upgPath : "(unknown path)");
|
||||||
} break;
|
} break;
|
||||||
#endif // __WINDOWS__ / __UNIX_LIKE__
|
#endif // __WINDOWS__ / __UNIX_LIKE__
|
||||||
|
|
||||||
case Node::NODE_UNRECOVERABLE_ERROR: {
|
case Node::NODE_UNRECOVERABLE_ERROR: {
|
||||||
exitCode = 3;
|
exitCode = 3;
|
||||||
const char *termReason = node->reasonForTermination();
|
const char *termReason = node->reasonForTermination();
|
||||||
fprintf(stderr,"%s: abnormal termination: %s\n",argv[0],(termReason) ? termReason : "(unknown reason)");
|
fprintf(stderr,"%s: abnormal termination: %s\n",argv[0],(termReason) ? termReason : "(unknown reason)");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete node;
|
delete node;
|
||||||
node = (Node *)0;
|
node = (Node *)0;
|
||||||
|
} catch ( std::exception &exc ) {
|
||||||
|
fprintf(stderr,"%s: unexpected exception: %s"ZT_EOL_S,argv[0],exc.what());
|
||||||
|
exitCode = 3;
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
fprintf(stderr,"%s: unexpected exception!"ZT_EOL_S,argv[0]);
|
fprintf(stderr,"%s: unexpected exception: unknown exception"ZT_EOL_S,argv[0]);
|
||||||
exitCode = 3;
|
exitCode = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include "OSXEthernetTapFactory.hpp"
|
#include "OSXEthernetTapFactory.hpp"
|
||||||
#include "OSXEthernetTap.hpp"
|
#include "OSXEthernetTap.hpp"
|
||||||
|
|
||||||
|
#include "../node/Utils.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
OSXEthernetTapFactory::OSXEthernetTapFactory(const char *pathToTapKext,const char *tapKextName) :
|
OSXEthernetTapFactory::OSXEthernetTapFactory(const char *pathToTapKext,const char *tapKextName) :
|
||||||
|
@ -47,6 +49,7 @@ OSXEthernetTapFactory::OSXEthernetTapFactory(const char *pathToTapKext,const cha
|
||||||
long kextpid = (long)vfork();
|
long kextpid = (long)vfork();
|
||||||
if (kextpid == 0) {
|
if (kextpid == 0) {
|
||||||
::chdir(_pathToTapKext.c_str());
|
::chdir(_pathToTapKext.c_str());
|
||||||
|
Utils::redirectUnixOutputs("/dev/null",(const char *)0);
|
||||||
::execl("/sbin/kextload","/sbin/kextload","-q","-repository",_pathToTapKext.c_str(),_tapKextName.c_str(),(const char *)0);
|
::execl("/sbin/kextload","/sbin/kextload","-q","-repository",_pathToTapKext.c_str(),_tapKextName.c_str(),(const char *)0);
|
||||||
::_exit(-1);
|
::_exit(-1);
|
||||||
} else if (kextpid > 0) {
|
} else if (kextpid > 0) {
|
||||||
|
@ -76,6 +79,7 @@ OSXEthernetTapFactory::~OSXEthernetTapFactory()
|
||||||
sprintf(tmp,"%s/%s",_pathToTapKext.c_str(),_tapKextName.c_str());
|
sprintf(tmp,"%s/%s",_pathToTapKext.c_str(),_tapKextName.c_str());
|
||||||
long kextpid = (long)vfork();
|
long kextpid = (long)vfork();
|
||||||
if (kextpid == 0) {
|
if (kextpid == 0) {
|
||||||
|
Utils::redirectUnixOutputs("/dev/null",(const char *)0);
|
||||||
::execl("/sbin/kextunload","/sbin/kextunload",tmp,(const char *)0);
|
::execl("/sbin/kextunload","/sbin/kextunload",tmp,(const char *)0);
|
||||||
::_exit(-1);
|
::_exit(-1);
|
||||||
} else if (kextpid > 0) {
|
} else if (kextpid > 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue