Commit 6023979d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Exit cleanly if there is no program (instead of busy looping).

parent cb930215
...@@ -180,9 +180,6 @@ int main(int argc, char *argv[]) ...@@ -180,9 +180,6 @@ int main(int argc, char *argv[])
/* make sure stdin, stdout and stderr exists */ /* make sure stdin, stdout and stderr exists */
if (dup (2) < 3) if (dup (2) < 3)
return 1; return 1;
/* closes all other file handles */
for (int fd = getdtablesize () - 1; fd > 2; fd--)
close (fd);
/* Get the programs */ /* Get the programs */
puts("+ Parsing configuration file\n"); puts("+ Parsing configuration file\n");
...@@ -194,6 +191,11 @@ int main(int argc, char *argv[]) ...@@ -194,6 +191,11 @@ int main(int argc, char *argv[])
/* TODO check configuration */ /* TODO check configuration */
printf("+ %u programs loaded\n",config.Programs.size()); printf("+ %u programs loaded\n",config.Programs.size());
if (config.Programs.size() == 0)
{
puts ("+ Nothing to do. Exiting.");
return 0;
}
if(config.GetType() == TYPE_SAP) if(config.GetType() == TYPE_SAP)
{ {
...@@ -237,7 +239,7 @@ int main(int argc, char *argv[]) ...@@ -237,7 +239,7 @@ int main(int argc, char *argv[])
daemon(0,0); daemon(0,0);
} }
unsigned n = config.Programs.size() ?: 1; unsigned n = config.Programs.size();
div_t d = div ((1000000000 / n) * config.GetDelay(), 1000000000); div_t d = div ((1000000000 / n) * config.GetDelay(), 1000000000);
struct timespec delay; struct timespec delay;
delay.tv_sec = d.quot; delay.tv_sec = d.quot;
......
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