Skip to content

Commit

Permalink
feat: created a function to handle sigkill
Browse files Browse the repository at this point in the history
  • Loading branch information
eiguike committed Mar 14, 2018
1 parent 8f30e7e commit 27c3886
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@
#include "device.h"
#include "fingerprint.h"

DEVICE* gDevice = NULL;

char* gUrl = "http://localhost:3000";
char* gPassword = "testelabpesquisa";

void
SignalHandler(
int Signal
)
{
printf("Exiting...\n");
if (gDevice != NULL) {
gDevice->Dispose(gDevice);
}

exit(0);
}

int main() {
//SERVER * Server = InitializeServer(8000);
//Server->Start(Server);
DEVICE* Device = NULL;

#ifdef WIRINGPILIB
// Initializing WiringPI
Expand All @@ -19,5 +36,21 @@ int main() {
printf("OK!\n");
#endif

Device = Device_Initialize(VERIFY_PROCESS);
signal(SIGINT, SignalHandler);
gDevice = Device_Init(VERIFY_PROCESS);

if (gDevice == NULL) {
printf("Something wrong happened...\n");
goto FINISH;
}

while(1) {
gDevice->Verify(gDevice);
if (gDevice->Outdated == 1) {
gDevice->Fingerprint->Update(gDevice->Fingerprint);
//gDevice->Fingerprint->Load(gDevice->Fingerprint);
}
}
FINISH:
return 0;
}

0 comments on commit 27c3886

Please sign in to comment.