Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch-contrib
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch-contrib
Commits
b2bba2a6
提交
b2bba2a6
authored
6月 16, 2010
作者:
Joao Mesquita
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do things the right way ignoring sigchild and using popen. Now I think its right.
上级
76dde4b6
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
33 行删除
+20
-33
eventsd.c
jmesquita/fs_eventsd/eventsd.c
+20
-33
没有找到文件。
jmesquita/fs_eventsd/eventsd.c
浏览文件 @
b2bba2a6
...
...
@@ -52,43 +52,29 @@ typedef struct {
static
inbound_event_profile_t
profiles
[
128
]
=
{{{
0
}}};
static
int
pcount
=
0
;
static
void
mycallback
(
esl_event_t
*
event
,
char
*
path
)
static
void
mycallback
(
esl_event_t
*
event
,
char
*
path
)
{
int
pipefd
[
2
];
int
pid
;
char
*
serialized
=
NULL
;
/*make a pipe (fds go in pipefd[0] and pipefd[1])*/
pipe
(
pipefd
);
pid
=
fork
();
if
(
pid
==
0
)
{
/* Wire fd to stdin */
dup2
(
pipefd
[
0
],
0
);
// close unused hald of pipe
close
(
pipefd
[
1
]);
// execute grep
execl
(
path
,
path
,
(
char
*
)
NULL
);
_exit
(
EXIT_SUCCESS
);
FILE
*
output
;
char
*
serialized
=
NULL
;
if
(
fork
()
==
0
)
{
output
=
popen
(
path
,
"w"
);
if
(
!
output
)
{
fprintf
(
stderr
,
"Could not execute script.
\n
"
);
exit
(
EXIT_FAILURE
);
}
else
/* Parent */
{
// close unused unput half of pipe
close
(
pipefd
[
0
]);
/* Pass information to new process */
esl_event_serialize
(
event
,
&
serialized
,
ESL_FALSE
);
write
(
pipefd
[
1
],
serialized
,
strlen
(
serialized
));
close
(
pipefd
[
1
]);
fprintf
(
output
,
"%s"
,
serialized
);
if
(
ferror
(
output
))
{
fprintf
(
stderr
,
"Output to stream failed.
\n
"
);
exit
(
EXIT_FAILURE
);
}
pclose
(
output
);
/* Might be already closed, but might as well try */
/* Free memory */
esl_safe_free
(
serialized
);
exit
(
0
);
}
return
;
}
static
int
usage
(
char
*
name
){
...
...
@@ -136,6 +122,7 @@ int main(int argc, char *argv[])
int
argv_conf
=
0
;
esl_global_set_default_logger
(
6
);
signal
(
SIGCHLD
,
SIG_IGN
);
for
(;;)
{
int
option_index
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论