- int fd;
-
- /* check in with launchd */
-#ifdef LION_TEST
- if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
-#else
- if ((checkin_response = launch_socket_service_check_in()) == NULL) {
-#endif
- plog(ASL_LEVEL_ERR,
- "failed to launch_socket_service_check_in.\n");
- goto done;
- }
-#ifdef LION_TEST
- if ((checkin_response = launch_msg(checkin_request)) == NULL) {
- plog(ASL_LEVEL_ERR, "failed to launch_msg.\n");
- goto done;
- }
-#endif
- if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
- plog(ASL_LEVEL_ERR,
- "launch_data_get_type error %d\n",
- launch_data_get_errno(checkin_response));
- goto done;
- }
- if ( (sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS)) == NULL){
- plog(ASL_LEVEL_ERR,
- "failed to launch_data_dict_lookup.\n");
- goto done;
- }
- if ( !(socketct = launch_data_dict_get_count(sockets_dict))){
- plog(ASL_LEVEL_ERR,
- "launch_data_dict_get_count returns no socket defined.\n");
- goto done;
- }
-
- if ( (listening_fd_array = launch_data_dict_lookup(sockets_dict, "Listeners")) == NULL ){
- plog(ASL_LEVEL_ERR,
- "failed to launch_data_dict_lookup.\n");
- goto done;
+ int *listening_fd_array = NULL;
+ size_t fd_count = 0;
+
+ int result = launch_activate_socket("Listeners", &listening_fd_array, &fd_count);
+ if (result != 0) {
+ plog(ASL_LEVEL_ERR, "failed to launch_activate_socket with error %s.\n", strerror(result));
+ return returnval;