void init(QSettings &set) { Q_ASSERT(qApp != NULL); qDebug() << "Initiating Q(Core)Application"; qApp->setApplicationName(APP_NAME); qApp->setOrganizationDomain(ORG_DOMAIN); qApp->setOrganizationName(ORG_DOMAIN); #ifndef CONSOLE qApp->setWindowIcon(QIcon(QStringLiteral(":/icon/svg"))); #endif if (qApp->arguments().contains(QStringLiteral("--killall"))) { killall(set); exit(EXIT_SUCCESS); } if (qApp->arguments().contains(QStringLiteral("--reset"))) { qDebug() << "<- Reset invoked"; killall(set); set.clear(); set.sync(); qDebug() << "-> Cleared settings"; } qDebug() << "Settings:" << set.fileName(); }
int main(int argc, char **argv) { int rv, i; int counter = 0; test_init(argc, argv); if (scale > MAX_SCALE) { err("Too many children specified\n"); exit(-1); } if (signal(SIGUSR2, do_stop) == SIG_ERR) { err("Can't setup handler\n"); exit(-1); } for (i = 0; i < scale; i++) { rv = test_fork(); if (rv == -1) { err("Can't fork\n"); killall(); exit(-1); } if (rv == 0) chew_some_file(i); pids[i] = rv; } test_daemon(); test_waitsig(); killall(); for (i = 0; i < scale; i++) { if (waitpid(pids[i], &rv, 0) == -1) { fail("Can't wipe up the kid\n"); counter++; continue; } if (!WIFEXITED(rv)) { fail("Kid was killed\n"); counter++; } else { rv = WEXITSTATUS(rv); if (rv < MAX_EXIT_CODE_VAL && rv > SUCCESS) { fail("Kid failed: %s (%d)\n", kids_fail_reasons[rv], rv); counter++; } else if (rv != SUCCESS) { fail("Unknow exitcode from kid: %d\n", rv); counter++; } } } if (counter == 0) pass(); return 0; }
void stop_nfs(void) { killall("portmap", SIGTERM); killall("statd", SIGTERM); killall("nfsd", SIGTERM); killall("mountd", SIGTERM); return; }
Face* nextface(void) { int i; Face *f; Plumbmsg *m; char *t, *senderp, *showmailp, *digestp; ulong xtime; f = emalloc(sizeof(Face)); for(;;){ if(seefd >= 0){ m = plumbrecv(seefd); if(m == nil) killall("error on seemail plumb port"); t = value(m->attr, "mailtype", ""); if(strcmp(t, "delete") == 0) delete(m->data, value(m->attr, "digest", nil)); else if(strcmp(t, "new") != 0) fprint(2, "faces: unknown plumb message type %s\n", t); else for(i=0; i<nmaildirs; i++) if(strncmp(m->data, maildirs[i], strlen(maildirs[i])) == 0) goto Found; plumbfree(m); continue; Found: xtime = parsedate(value(m->attr, "date", date)); digestp = value(m->attr, "digest", nil); if(alreadyseen(digestp)){ /* duplicate upas/fs can send duplicate messages */ plumbfree(m); continue; } senderp = estrdup(value(m->attr, "sender", "???")); showmailp = estrdup(m->data); if(digestp) digestp = estrdup(digestp); plumbfree(m); }else{ if(logrecv(&senderp, &xtime) <= 0) killall("error reading log file"); showmailp = estrdup(""); digestp = nil; } setname(f, senderp); f->time = xtime; f->tm = *localtime(xtime); f->str[Sshow] = showmailp; f->str[Sdigest] = digestp; return f; } }
void stop_dhcpc(void) { _dprintf("%s: begin\n", __FUNCTION__); killall("dhcpc-event", SIGTERM); if (killall("udhcpc", SIGUSR2) == 0) { // release sleep(2); } killall_tk("udhcpc"); unlink(renewing); _dprintf("%s: end\n", __FUNCTION__); }
void wo_iptbackup(char *url) { struct stat st; time_t t; int i; if (stat(ifn, &st) == 0) { t = st.st_mtime; sleep(1); } else { t = 0; } killall("cstats", SIGHUP); for (i = 20; i > 0; --i) { // may take a long time for gzip to complete if ((stat(ifn, &st) == 0) && (st.st_mtime != t)) break; sleep(1); } if (i == 0) { send_error(500, NULL, NULL); return; } send_header(200, NULL, mime_binary, 0); do_file((char *)ifn); }
void broadcast_signal(int sig, bool wait_for_exit) { sigset_t mask, oldmask; Set *pids = NULL; if (wait_for_exit) pids = set_new(trivial_hash_func, trivial_compare_func); assert_se(sigemptyset(&mask) == 0); assert_se(sigaddset(&mask, SIGCHLD) == 0); assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) == 0); if (kill(-1, SIGSTOP) < 0 && errno != ESRCH) log_warning("kill(-1, SIGSTOP) failed: %m"); killall(sig, pids); if (kill(-1, SIGCONT) < 0 && errno != ESRCH) log_warning("kill(-1, SIGCONT) failed: %m"); if (wait_for_exit) wait_for_children(pids, &mask); assert_se(sigprocmask(SIG_SETMASK, &oldmask, NULL) == 0); set_free(pids); }
void dropgraph(int which) { Graph *ograph; int i, j, n; if(which > nelem(menu2str)) abort(); /* convert n to index in graph table */ n = -1; for(i=0; i<ngraph; i++) if(strcmp(menu2str[which]+Opwid, graph[i].label) == 0){ n = i; break; } if(n < 0){ fprint(2, "stats: internal error can't drop graph\n"); killall("error"); } ograph = graph; graph = emalloc(nmach*(ngraph-1)*sizeof(Graph)); for(i=0; i<nmach; i++){ for(j=0; j<n; j++) graph[i*(ngraph-1)+j] = ograph[i*ngraph+j]; free(ograph[i*ngraph+j].data); freeimage(ograph[i*ngraph+j].overtmp); for(j++; j<ngraph; j++) graph[i*(ngraph-1)+j-1] = ograph[i*ngraph+j]; } free(ograph); ngraph--; present[which] = 0; }
int run_wiviz_main(int argc, char **argv) { pid_t pid; pid = fork(); switch (pid) { case -1: perror("fork failed"); exit(1); break; case 0: if (pidof("wiviz") > 0) killall("wiviz", SIGUSR1); else { char *hopseq = nvram_safe_get("hopseq"); FILE *fp = fopen("/tmp/wiviz2-cfg", "wb"); if (nvram_match("hopseq", "0")) fprintf(fp, "channelsel=hop&"); else if (strstr(hopseq, ",")) fprintf(fp, "channelsel=hop&"); else fprintf(fp, "channelsel=%s&", hopseq); fprintf(fp, "hopdwell=%s&hopseq=%s\n", nvram_safe_get("hopdwell"), hopseq); fclose(fp); eval("wiviz", ">/dev/null", "</dev/null", "2>&1", "&"); } exit(0); break; default: _exit(0); break; } }
void start_upnp(void) { if (nvram_match("wan_proto", "disabled")) return; char *wan_ifname = get_wan_face(); int ret; if (nvram_match("upnp_enable", "0")) { stop_upnp(); return; } /* * Make sure its not running first */ ret = killall("upnp", SIGUSR1); if (ret != 0) { /* ret = eval( "upnp", "-D", "-L", nvram_safe_get( "lan_ifname" ), "-W", wan_ifname, "-S", "0", "-I", nvram_safe_get( "upnp_ssdp_interval" ), "-A", nvram_safe_get( "upnp_max_age" ) );*/ ret = eval("upnp", "-D", "-W", wan_ifname); dd_syslog(LOG_INFO, "upnp : upnp daemon successfully started\n"); } cprintf("done\n"); return; }
int do_mon(void) { struct mon *v; checkupgrade(); checknas(); #ifndef HAVE_RT2880 softcontrol_wlan_led(); #endif for (v = mons; v < &mons[sizeof(mons) / sizeof(struct mon)]; v++) { if (v->name == NULL) break; if (v->nvvalue && v->nvmatch) { if (!nvram_match(v->nvvalue, v->nvmatch)) continue; // service not enabled. no need to check } printf("checking %s\n", v->name); if (v->type == M_WAN) if (!check_wan_link(0)) { printf("process is wan, but wan is not up\n"); continue; } if (!search_process(v->name, v->count)) { printf("Maybe %s had died, we need to re-exec it\n", v->name); sysprintf("stopservice %s", v->name); killall(v->name, SIGKILL); sysprintf("startservice_f %s", v->name); } printf("checking for %s done\n", v->name); } return 1; }
void wo_bwmbackup(char *url) { struct stat st; time_t t; int i; if (stat(hfn, &st) == 0) { t = st.st_mtime; sleep(1); } else { t = 0; } killall("rstats", SIGHUP); for (i = 10; i > 0; --i) { if ((stat(hfn, &st) == 0) && (st.st_mtime != t)) break; sleep(1); } if (i == 0) { send_error(500, NULL, NULL); return; } send_header(200, NULL, mime_binary, 0); do_file((char *)hfn); }
void stop_rstats(void) { if (pidof("rstats") > 0) { dd_syslog(LOG_INFO, "rstats : rstats daemon successfully stopped\n"); killall("rstats", SIGTERM); } }
int main(int argc, char **argv) { /* * Run it in the background */ switch (fork()) { case -1: // can't fork exit(0); break; case 0: /* * child process */ // fork ok (void)setsid(); break; default: /* * parent process should just die */ _exit(0); } int timeout = atoi(argv[1]); while (timeout) { FILE *fp = fopen("/tmp/.wpsdone", "rb"); if (fp) { killall("ledtool", SIGKILL); nvram_set("wps_status", "1"); nvram_commit(); sysprintf("rm -f /tmp/.wpsdone"); fclose(fp); led_control(LED_SES, LED_ON); break; } timeout--; sleep(1); } if (!timeout) { killall("ledtool", SIGKILL); nvram_set("wps_status", "1"); nvram_commit(); system("ledtool 1800 3"); } return 0; } // end main
int Wireless::closeNetwork() { int status = 0; status = iw( WLAN_DEV, "disconnect", "" ); status = killall( "wpa_supplicant" ); status = ifconfig( WLAN_DEV, "up", "" ); return status; }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_killall_process, ev, data) { PROCESS_BEGIN(); killall(); PROCESS_END(); }
void reset_nocat( void ) { if( pidof( "splashd" ) > 0 ) { syslog( LOG_INFO, "splashd : Reseting splashd firewall rules\n" ); killall( "splashd", SIGUSR1); } return; }
char* estrdup(char *s) { char *t; if((t = strdup(s)) == nil) { fprint(2, "stats: out of memory in strdup(%.10s): %r\n", s); killall("mem"); } return t; }
void* erealloc(void *v, uint32_t sz) { v = realloc(v, sz); if(v == nil) { fprint(2, "stats: out of memory reallocating %ld: %r\n", sz); killall("mem"); } return v; }
void killall_tk(const char *name) { int n; if (killall(name, SIGTERM) == 0) { n = 5; while ((killall(name, 0) == 0) && (n-- > 0)) { _dprintf("%s: waiting name=%s n=%d\n", __FUNCTION__, name, n); sleep(1); } if (n < 0) { n = 5; while ((killall(name, SIGKILL) == 0) && (n-- > 0)) { _dprintf("%s: SIGKILL name=%s n=%d\n", __FUNCTION__, name, n); sleep(2); } } } }
int stop_rcamd(void) { killall("mjpg_streamer"); rmmod("uvcvideo"); rmmod("input-core"); rmmod("v4l2-common"); rmmod("videodev"); return 0; }
void read_wbuf(int fd, wbuf *buf, xfs_mount_t *mp) { int res = 0; xfs_off_t lres = 0; xfs_off_t newpos; size_t diff; newpos = rounddown(buf->position, (xfs_off_t) buf->min_io_size); if (newpos != buf->position) { diff = buf->position - newpos; buf->position = newpos; buf->length += diff; } if (source_position != buf->position) { lres = lseek64(fd, buf->position, SEEK_SET); if (lres < 0LL) { do_warn(_("%s: lseek64 failure at offset %lld\n"), progname, source_position); die_perror(); } source_position = buf->position; } ASSERT(source_position % source_sectorsize == 0); /* round up length for direct I/O if necessary */ if (buf->length % buf->min_io_size != 0) buf->length = roundup(buf->length, buf->min_io_size); if (buf->length > buf->size) { do_warn(_("assert error: buf->length = %d, buf->size = %d\n"), buf->length, buf->size); killall(); abort(); } if ((res = read(fd, buf->data, buf->length)) < 0) { do_warn(_("%s: read failure at offset %lld\n"), progname, source_position); die_perror(); } if (res < buf->length && source_position + res == mp->m_sb.sb_dblocks * source_blocksize) res = buf->length; else ASSERT(res == buf->length); source_position += res; buf->length = res; }
void* emalloc(uint32_t sz) { void *v; v = malloc(sz); if(v == nil) { fprint(2, "stats: out of memory allocating %ld: %r\n", sz); killall("mem"); } memset(v, 0, sz); return v; }
void asp_upnpinfo(int argc, char **argv) { if (nvram_get_int("upnp_enable")) { f_write_string("/etc/upnp/info", "", 0, 0); if (killall("miniupnpd", SIGUSR2) == 0) { f_wait_notexists("/etc/upnp/info", 5); } web_puts("\nmupnp_data = '"); web_putfile("/etc/upnp/data.info", WOF_JAVASCRIPT); web_puts("';\n"); } }
int stop_process(char *name, char *desc) { if (!desc) desc = name; if (pidof(name) > 0) { dd_syslog(LOG_INFO, "%s : %s successfully stopped\n", name, desc); killall(name, SIGTERM); int deadcounter = 20; while (pidof(name) > 0 && deadcounter--) { usleep(100*1000); } if (pidof(name) > 0) { dd_syslog(LOG_INFO, "%s : %s hanging, send SIGKILL\n", name, desc); killall(name, SIGKILL); } return 1; } return 0; }
int dhcpc_release_main(int argc, char **argv) { _dprintf("%s: begin\n", __FUNCTION__); if (!using_dhcpc()) return 1; deconfig(nvram_safe_get("wan_ifname")); killall("udhcpc", SIGUSR2); unlink(renewing); unlink("/var/lib/misc/wan.connecting"); _dprintf("%s: end\n", __FUNCTION__); return 0; }
void wi_bwmrestore(char *url, int len, char *boundary) { char *buf; const char *error; int ok; int n; char tmp[64]; check_id(url); tmp[0] = 0; buf = NULL; error = "Error reading file"; ok = 0; if (!skip_header(&len)) { goto ERROR; } if ((len < 64) || (len > 10240)) { goto ERROR; } if ((buf = malloc(len)) == NULL) { error = "Not enough memory"; goto ERROR; } n = web_read(buf, len); len -= n; sprintf(tmp, "%s.new", hfn); if (f_write(tmp, buf, n, 0, 0600) != n) { unlink(tmp); error = "Error writing temporary file"; goto ERROR; } f_write("/var/tmp/rstats-load", NULL, 0, 0, 0600); killall("rstats", SIGHUP); sleep(1); error = NULL; rboot = 1; // used as "ok" ERROR: free(buf); web_eat(len); if (error != NULL) resmsg_set(error); }
void wo_trace(char *url) { char cmd[256]; const char *addr; addr = webcgi_get("addr"); if (!check_addr(addr, 64)) return; killall("traceroute", SIGTERM); web_puts("\ntracedata = '"); sprintf(cmd, "traceroute -I -m %u -w %u %s", atoi(webcgi_safeget("hops", "0")), atoi(webcgi_safeget("wait", "0")), addr); web_pipecmd(cmd, WOF_JAVASCRIPT); web_puts("';"); }
void wo_ping(char *url) { char cmd[256]; const char *addr; addr = webcgi_get("addr"); if (!check_addr(addr, 64)) return; killall("ping", SIGTERM); web_puts("\npingdata = '"); sprintf(cmd, "ping -c %d -s %d %s", atoi(webcgi_safeget("count", "0")), atoi(webcgi_safeget("size", "0")), addr); web_pipecmd(cmd, WOF_JAVASCRIPT); web_puts("';"); }
void start_apserv(void) { char *wan_ifname = get_wan_face(); int ret; if (nvram_match("apserv_enable", "0")) { stop_apserv(); return; } /* * Make sure its not running first */ ret = killall("ap_serv", SIGUSR1); ret = eval("ap_serv", "-i", nvram_safe_get("lan_ifname")); dd_syslog(LOG_INFO, "ap_serv : ap_serv daemon successfully started\n"); cprintf("done\n"); return; }