FS-5166 --resolve exec for windows
This commit is contained in:
parent
77ee3fe10c
commit
16289ce9a4
|
@ -1230,10 +1230,26 @@ static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_
|
||||||
static FILE *preprocess_exec(const char *cwd, const char *command, FILE *write_fd, int rlevel)
|
static FILE *preprocess_exec(const char *cwd, const char *command, FILE *write_fd, int rlevel)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
char message[] = "<!-- exec not implemented in windows yet -->";
|
FILE *fp = NULL;
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
if (fwrite( message, 1, sizeof(message), write_fd) < 0) {
|
if (!command || !strlen(command)) goto end;
|
||||||
goto end;
|
|
||||||
|
if ((fp = _popen(command, "r"))) {
|
||||||
|
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
|
||||||
|
if (fwrite(buffer, 1, strlen(buffer), write_fd) <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(feof(fp)) {
|
||||||
|
_pclose(fp);
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Exec failed to read the pipe of [%s] to the end\n", command);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch_snprintf(buffer, sizeof(buffer), "<!-- exec can not execute [%s] -->", command);
|
||||||
|
fwrite( buffer, 1, strlen(buffer), write_fd);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int fds[2], pid = 0;
|
int fds[2], pid = 0;
|
||||||
|
|
Loading…
Reference in New Issue