/* * This file is part of firk's window manager for x11 (fwm) * Copyright (C) 2016-2021 firk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include #include "main.h" #include "runprog.h" extern char * * environ; extern void run_command(char const * cmdline) { int i; pid_t p; char const * argv[4]; p = fork(); if(p<0) { logprint("fork() error %d (%s)", errno, strerror(errno)); return; } if(p>0) return; for(i=3; i<1000; i++) close(i); argv[0] = "/bin/sh"; argv[1] = "-c"; argv[2] = cmdline; argv[3] = NULL; execve("/bin/sh", (char**)argv, environ); _exit(-1); }