Fix execute_script().
This commit is contained in:
parent
2de5e0eef9
commit
7d07df71f9
1 changed files with 10 additions and 8 deletions
|
@ -17,7 +17,7 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
$Id: process.c,v 1.1.2.38 2002/03/24 16:22:59 guus Exp $
|
$Id: process.c,v 1.1.2.39 2002/03/26 12:00:38 guus Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -207,10 +207,9 @@ cp
|
||||||
Execute the program name, with sane environment. All output will be
|
Execute the program name, with sane environment. All output will be
|
||||||
redirected to syslog.
|
redirected to syslog.
|
||||||
*/
|
*/
|
||||||
void _execute_script(const char *name) __attribute__ ((noreturn));
|
void _execute_script(const char *scriptname) __attribute__ ((noreturn));
|
||||||
void _execute_script(const char *name)
|
void _execute_script(const char *scriptname)
|
||||||
{
|
{
|
||||||
char *scriptname;
|
|
||||||
char *s;
|
char *s;
|
||||||
cp
|
cp
|
||||||
#ifdef HAVE_UNSETENV
|
#ifdef HAVE_UNSETENV
|
||||||
|
@ -239,8 +238,6 @@ cp
|
||||||
|
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
asprintf(&scriptname, "%s/%s", confbase, name);
|
|
||||||
|
|
||||||
/* Close all file descriptors */
|
/* Close all file descriptors */
|
||||||
closelog(); /* <- this means we cannot use syslog() here anymore! */
|
closelog(); /* <- this means we cannot use syslog() here anymore! */
|
||||||
fcloseall();
|
fcloseall();
|
||||||
|
@ -262,10 +259,13 @@ int execute_script(const char *name)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
char *scriptname;
|
||||||
cp
|
cp
|
||||||
|
asprintf(&scriptname, "%s/%s", confbase, name);
|
||||||
|
|
||||||
/* First check if there is a script */
|
/* First check if there is a script */
|
||||||
|
|
||||||
if(stat(name, &s))
|
if(stat(scriptname, &s))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if((pid = fork()) < 0)
|
if((pid = fork()) < 0)
|
||||||
|
@ -279,6 +279,8 @@ cp
|
||||||
if(debug_lvl >= DEBUG_STATUS)
|
if(debug_lvl >= DEBUG_STATUS)
|
||||||
syslog(LOG_INFO, _("Executing script %s"), name);
|
syslog(LOG_INFO, _("Executing script %s"), name);
|
||||||
|
|
||||||
|
free(scriptname);
|
||||||
|
|
||||||
if(waitpid(pid, &status, 0) == pid)
|
if(waitpid(pid, &status, 0) == pid)
|
||||||
{
|
{
|
||||||
if(WIFEXITED(status)) /* Child exited by itself */
|
if(WIFEXITED(status)) /* Child exited by itself */
|
||||||
|
@ -312,7 +314,7 @@ cp
|
||||||
cp
|
cp
|
||||||
/* Child here */
|
/* Child here */
|
||||||
|
|
||||||
_execute_script(name);
|
_execute_script(scriptname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue