Skip to content

Support daemon(fork twice) for Darwin/OSX #23

Closed
@winlinvip

Description

SRS分支改进后,去掉了对多进程的检测,而OSX在fork后会关闭fd,导致kevent返回-1死循环。

在初始化时调用_st_kq_init创建了kqueue,fd是3:

(lldb) p _st_kq_data->kq
(int) $0 = 3

MB0:state-threads winlin$ lsof -p 31372|grep KQUEUE
srs     31372 winlin    3u  KQUEUE                                       count=0, state=0

运行后,daemon经过两次fork,fd=3已经关闭,变成了pid文件了:

MB0:state-threads winlin$ lsof -p 31695
COMMAND   PID  USER   FD   TYPE             DEVICE   SIZE/OFF                NODE NAME
srs     31695 winlin    3w   REG                1,4          5            31611904 /Users/winlin/git/srs/trunk/objs/srs.pid

最初是有pid改变的检测的( event.c#L970 ),由于在linux下没有用多进程,所以在这个分支去掉了这个逻辑。

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions