summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-09-09 17:56:51 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-09-09 17:56:51 +0200
commit275a09d6c5ca1c1b03cfc74a5f856c7304adc80c (patch)
tree1fefe9e0fa5217a6a34280de655b3255b1c852ad /main.c
parent8ddaf5d7688b14590f283b2ebb81f78326fb39fd (diff)
downloadnetifd-275a09d6c5ca1c1b03cfc74a5f856c7304adc80c.tar.gz
add an ubus call for restarting netifd
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/main.c b/main.c
index dc69abc..d1f976d 100644
--- a/main.c
+++ b/main.c
@@ -7,6 +7,22 @@
#include "ubus.h"
#include "config.h"
+static char **global_argv;
+
+static void netifd_do_restart(struct uloop_timeout *timeout)
+{
+ execvp(global_argv[0], global_argv);
+}
+
+static struct uloop_timeout restart_timer = {
+ .cb = netifd_do_restart,
+};
+
+void netifd_restart(void)
+{
+ uloop_timeout_set(&restart_timer, 1000);
+}
+
static int usage(const char *progname)
{
fprintf(stderr, "Usage: %s [options]\n"
@@ -22,6 +38,8 @@ int main(int argc, char **argv)
const char *socket = NULL;
int ch;
+ global_argv = argv;
+
while ((ch = getopt(argc, argv, "s:")) != -1) {
switch(ch) {
case 's':