애플은 launchd
오픈 소스 화 가지고 있으며, 소스 코드 http://opensource.apple.com/source/launchd/launchd-442.26.2/
launchctl
의 소스 코드가 support/launchctl.c에에서 확인할 수있다. 다행히도 당신이 거기에서 당신이 필요로하는 것을 찾을 수 있어야합니다. 나는 당신이 파일의 아래 약 2/3에 관해서 list_cmd
기능을 볼 필요가 있다고 생각한다.
답변이 launchctl.c
이 아니라면 다른 곳이 어디인지 정말로 알 수 없습니다.
처음에는 launchctl
바이너리에서 기호를 찾기 시작했습니다.
bootstrap_look_up()
기능은 launchd/liblaunch/libbootstrap.c
에 정의 된 것으로 보입니다. nm /bin/launchctl
을 실행
흥미로운 심볼을 제공합니다 :
...
U _bootstrap_get_root
U _bootstrap_info
U _bootstrap_look_up_per_user
U _bootstrap_lookup_children
U _bootstrap_parent
U _bootstrap_port
...
U _launch_data_alloc
U _launch_data_array_get_count
U _launch_data_array_get_index
U _launch_data_array_set_index
U _launch_data_copy
U _launch_data_dict_insert
U _launch_data_dict_iterate
U _launch_data_dict_lookup
U _launch_data_dict_remove
U _launch_data_free
U _launch_data_get_bool
U _launch_data_get_errno
U _launch_data_get_fd
U _launch_data_get_integer
U _launch_data_get_machport
U _launch_data_get_opaque
U _launch_data_get_opaque_size
U _launch_data_get_real
U _launch_data_get_string
U _launch_data_get_type
U _launch_data_new_bool
U _launch_data_new_fd
U _launch_data_new_opaque
U _launch_data_new_string
U _launch_data_set_bool
U _launch_data_set_integer
U _launch_data_set_opaque
U _launch_data_set_real
U _launch_data_set_string
U _launch_msg
...
는이 launch_data_
기능 launchd/launch/liblaunch.c
선언을 한 것으로 나타났습니다.
내가 알 수있는 한 liblaunch
은 시스템 라이브러리로 설치되어 있지 않으며 libSystem
에는이 기호가 포함되어 있지 않습니다 (단지 bootstrap_init
이 내보내 짐).
launchd
소스를 다운로드하고 자신의 liblaunch
을 컴파일하고 프로젝트에 연결하여 필요한 기능을 사용할 수 있는지 확인하는 것이 좋습니다. 나는 이것이 당신이 원하는 것을 할 수 있는지 전혀 모른다.
왜 launchctl 목록을 사용하지 않습니까? –
첫 번째 단락에서 말했듯이 fork/exec에서 launchctl list를 사용하고 있습니다. 나는 모든 프로세스를 포기하지 않고 함수 호출을하고 싶다. – spartygw
use pthread_create() –