@@ -36,14 +36,22 @@ int uv__set_process_title(const char* title) {
3636 CFStringRef ,
3737 CFStringRef ,
3838 CFDictionaryRef * );
39+ typedef CFDictionaryRef (* LSApplicationCheckInType )(int , CFDictionaryRef );
40+ typedef OSStatus (* SetApplicationIsDaemonType )(int );
41+ typedef void (* LSSetApplicationLaunchServicesServerConnectionStatusType )(
42+ uint64_t , void * );
3943 CFBundleRef launch_services_bundle ;
4044 LSGetCurrentApplicationASNType ls_get_current_application_asn ;
4145 LSSetApplicationInformationItemType ls_set_application_information_item ;
4246 CFStringRef * display_name_key ;
43- ProcessSerialNumber psn ;
4447 CFTypeRef asn ;
4548 CFStringRef display_name ;
4649 OSStatus err ;
50+ CFBundleRef hi_services_bundle ;
51+ LSApplicationCheckInType ls_application_check_in ;
52+ SetApplicationIsDaemonType set_application_is_daemon ;
53+ LSSetApplicationLaunchServicesServerConnectionStatusType
54+ ls_set_application_launch_services_server_connection_status ;
4755
4856 launch_services_bundle =
4957 CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.LaunchServices" ));
@@ -71,8 +79,36 @@ int uv__set_process_title(const char* title) {
7179 if (display_name_key == NULL || * display_name_key == NULL )
7280 return -1 ;
7381
74- /* Force the process manager to initialize. */
75- GetCurrentProcess (& psn );
82+ /* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
83+ hi_services_bundle =
84+ CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.HIServices" ));
85+ if (hi_services_bundle == NULL )
86+ return -1 ;
87+
88+ set_application_is_daemon = CFBundleGetFunctionPointerForName (
89+ hi_services_bundle ,
90+ CFSTR ("SetApplicationIsDaemon" ));
91+ ls_application_check_in = CFBundleGetFunctionPointerForName (
92+ launch_services_bundle ,
93+ CFSTR ("_LSApplicationCheckIn" ));
94+ ls_set_application_launch_services_server_connection_status =
95+ CFBundleGetFunctionPointerForName (
96+ launch_services_bundle ,
97+ CFSTR ("_LSSetApplicationLaunchServicesServerConnectionStatus" ));
98+ if (set_application_is_daemon == NULL ||
99+ ls_application_check_in == NULL ||
100+ ls_set_application_launch_services_server_connection_status == NULL ) {
101+ return -1 ;
102+ }
103+
104+ if (set_application_is_daemon (1 ) != noErr )
105+ return -1 ;
106+
107+ ls_set_application_launch_services_server_connection_status (0 , NULL );
108+
109+ /* Check into process manager?! */
110+ ls_application_check_in (-2 ,
111+ CFBundleGetInfoDictionary (CFBundleGetMainBundle ()));
76112
77113 display_name = CFStringCreateWithCString (NULL , title , kCFStringEncodingUTF8 );
78114 asn = ls_get_current_application_asn ();
0 commit comments