X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fcmd_neonserv_extscript.c;h=21aad8b9f0abb844d2fb26c9e50126906eb3f2bb;hb=1b3cffe710e805d2d95bc622f906d7d15440931d;hp=37d6f9109805a5b0e95b0009440864d061b142c6;hpb=46a731f9da7ecfa38a6859e933c2c1e452429527;p=NeonServV5.git diff --git a/src/cmd_neonserv_extscript.c b/src/cmd_neonserv_extscript.c index 37d6f91..21aad8b 100644 --- a/src/cmd_neonserv_extscript.c +++ b/src/cmd_neonserv_extscript.c @@ -111,15 +111,15 @@ CMD_BIND(neonserv_cmd_extscript) { } command[commandpos] = '\0'; //we should now have a valid command - FILE *fp; - fp = popen(command, "r"); - if (fp) { - struct ClientSocket *textbot = getTextBot(); - pid_t pID = fork(); - if (pID == 0) { //We're the child process :D - pID = fork(); - if(pID < 0) exit(EXIT_FAILURE); - if(pID != 0) exit(EXIT_SUCCESS); + struct ClientSocket *textbot = getTextBot(); + pid_t pID = fork(); + if (pID == 0) { //We're the child process :D + pID = fork(); + if(pID < 0) exit(EXIT_FAILURE); + if(pID != 0) exit(EXIT_SUCCESS); + FILE *fp; + fp = popen(command, "r"); + if (fp) { char *a; while (fgets(command, 1024, fp) != NULL) { if((a = strchr(command, '\n'))) @@ -130,18 +130,15 @@ CMD_BIND(neonserv_cmd_extscript) { reply(textbot, user, "%s", command); } pclose(fp); - exit(EXIT_FAILURE); - } else if (pID < 0) { - reply(getTextBot(), user, "internal bot error - please contact an administrator!"); - pclose(fp); } else { - //parent bot - continue program - wait(NULL); + reply(getTextBot(), user, "internal bot error - please contact an administrator!"); } - } else { - //error + exit(EXIT_FAILURE); + } else if (pID < 0) { reply(getTextBot(), user, "internal bot error - please contact an administrator!"); - return; + } else { + //parent bot - continue program + wait(NULL); } }