2013-06-11 1 views
1

launchd를 통해 서비스가 활성화되어있는 경우 C/C++에서 확인하는 방법을 알 수 없습니다. 나는 명령 줄에서 launchctl을 사용할 수 있으며 현재 fork/exec에서 'launchctl list myServiceName'을 실행 중임을 알고 있습니다.launchd에서 서비스가 활성화되었는지 확인하는 방법

나는 boostrap_look_up()이이를 확인하는 방법 일지 모르지만 간단한 예제를 요약하기에 충분한 문서를 찾을 수 없다는 것을 알았다.

당신은 이것을 비추어 줄 수 있습니까? 내 서비스가 실제로 등록되어 있고 사용 가능한지 테스트 할 수있는 작은 기능 만 있으면됩니다.

+0

왜 launchctl 목록을 사용하지 않습니까? –

+0

첫 번째 단락에서 말했듯이 fork/exec에서 launchctl list를 사용하고 있습니다. 나는 모든 프로세스를 포기하지 않고 함수 호출을하고 싶다. – spartygw

+0

use pthread_create() –

답변

1

애플은 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을 컴파일하고 프로젝트에 연결하여 필요한 기능을 사용할 수 있는지 확인하는 것이 좋습니다. 나는 이것이 당신이 원하는 것을 할 수 있는지 전혀 모른다.

+0

답변 해 주셔서 감사합니다. 내가 일할 수 있는지 알기 위해 시간이 좀 걸릴 것입니다. 그러나 나는 당신의 대답을 받아들이기에 충분합니다. 너는 내가 전에 없었던 곳에서 나에게 리드를 주었다. – spartygw

관련 문제