Exemple #1
0
/** Execute a system command
 * \param cmd Command
 * \return child pid
*/
pid_t
spawn(const char *format, ...)
{
     char *sh = NULL;
     char cmd[512];
     va_list ap;
     pid_t pid;
     size_t len;

     va_start(ap, format);
     len = vsnprintf(cmd, sizeof(cmd), format, ap);
     va_end(ap);

     if (len >= sizeof(cmd))
     {
          warnxl("command too long (> 512 bytes)");
          return -1;
     }

     if(!(sh = getenv("SHELL")) || sh[0] != '/')
          sh = "/bin/sh";

     if(!(pid = fork()))
     {
          setsid();
          if (execl(sh, sh, "-c", cmd, (char*)NULL) == -1)
               warnl("execl(sh -c %s)", cmd);
          exit(EXIT_FAILURE);
     }
     else if (pid == -1)
          warnl("fork");

     return pid;
}
Exemple #2
0
void
nilopt(Prog *firstp)
{
	NilFlow *r;
	Prog *p;
	Graph *g;
	int ncheck, nkill;

	g = flowstart(firstp, sizeof(NilFlow));
	if(g == nil)
		return;

	if(debug_checknil > 1 /* || strcmp(curfn->nname->sym->name, "f1") == 0 */)
		dumpit("nilopt", g->start, 0);

	ncheck = 0;
	nkill = 0;
	for(r = (NilFlow*)g->start; r != nil; r = (NilFlow*)r->f.link) {
		p = r->f.prog;
		if(p->as != ACHECKNIL || !regtyp(&p->from))
			continue;
		ncheck++;
		if(stackaddr(&p->from)) {
			if(debug_checknil && p->lineno > 1)
				warnl(p->lineno, "removed nil check of SP address");
			r->kill = 1;
			continue;
		}
		nilwalkfwd(r);
		if(r->kill) {
			if(debug_checknil && p->lineno > 1)
				warnl(p->lineno, "removed nil check before indirect");
			continue;
		}
		nilwalkback(r);
		if(r->kill) {
			if(debug_checknil && p->lineno > 1)
				warnl(p->lineno, "removed repeated nil check");
			continue;
		}
	}
	
	for(r = (NilFlow*)g->start; r != nil; r = (NilFlow*)r->f.link) {
		if(r->kill) {
			nkill++;
			excise(&r->f);
		}
	}

	flowend(g);
	
	if(debug_checknil > 1)
		print("%S: removed %d of %d nil checks\n", curfn->nname->sym, nkill, ncheck);
}
Exemple #3
0
void
config_init(void)
{
     if(get_conf(W->confpath) == -1)
     {
          warnl("parsing configuration file (%s) failed.", W->confpath);
          sprintf(W->confpath, "%s/"CONFIG_DEFAULT_PATH, getenv("HOME"));

          if(get_conf(W->confpath) == -1)
          {
               warnxl("parsing default configuration file (%s) failed.", W->confpath);
               sprintf(W->confpath, "%s/wmfs/wmfsrc", XDG_CONFIG_DIR);

               if(get_conf(W->confpath) == -1)
                   errxl(1, "parsing system configuration file (%s) failed.", W->confpath);
          }
     }

     config_theme();
     config_keybind();
     config_tag();
     config_client();
     config_bars();
     config_rule();
     config_launcher();

     free_conf();
}