Use negative return values on errors
This commit is contained in:
2
cui.cpp
2
cui.cpp
@@ -430,7 +430,7 @@ void do_refresh()
|
||||
}
|
||||
else
|
||||
{
|
||||
forceExit("Invalid viewmode");
|
||||
forceExit("Invalid viewmode", -1);
|
||||
}
|
||||
uid_t uid = curproc->getVal()->getUid();
|
||||
#ifndef NDEBUG
|
||||
|
||||
@@ -222,7 +222,7 @@ void quit_cb (int /* i */)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void forceExit(const char *msg, ...)
|
||||
void forceExit(const char *msg, int errcode, ...)
|
||||
{
|
||||
if ((!tracemode)&&(!DEBUG)){
|
||||
exit_ui();
|
||||
@@ -234,7 +234,7 @@ void forceExit(const char *msg, ...)
|
||||
va_end(argp);
|
||||
std::cerr << std::endl;
|
||||
|
||||
exit(0);
|
||||
exit(errcode);
|
||||
}
|
||||
|
||||
static void versiondisplay(void)
|
||||
@@ -331,7 +331,7 @@ int main (int argc, char** argv)
|
||||
}
|
||||
|
||||
if (NEEDROOT && (getuid() != 0))
|
||||
forceExit("You need to be root to run NetHogs!");
|
||||
forceExit("You need to be root to run NetHogs!", -2);
|
||||
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#define PROGNAME_WIDTH 512
|
||||
|
||||
void forceExit(const char *msg, ...);
|
||||
void forceExit(const char *msg, int errcode, ...);
|
||||
|
||||
class local_addr {
|
||||
public:
|
||||
|
||||
@@ -61,11 +61,11 @@ void getLocal (const char *device, bool tracemode)
|
||||
struct sockaddr_in *saddr;
|
||||
|
||||
if((sock=socket(AF_INET, SOCK_RAW, htons(0x0806)))<0){
|
||||
forceExit("creating socket failed while establishing local IP - are you root?");
|
||||
forceExit("creating socket failed while establishing local IP - are you root?", -3);
|
||||
}
|
||||
strcpy(iFreq.ifr_name, device);
|
||||
if(ioctl(sock, SIOCGIFADDR, &iFreq)<0){
|
||||
forceExit("ioctl failed while establishing local IP for selected device %s. You may specify the device on the command line.", device);
|
||||
forceExit("ioctl failed while establishing local IP for selected device %s. You may specify the device on the command line.", -4, device);
|
||||
}
|
||||
saddr=(struct sockaddr_in*)&iFreq.ifr_addr;
|
||||
local_addrs = new local_addr (saddr->sin_addr.s_addr, local_addrs);
|
||||
|
||||
Reference in New Issue
Block a user