[launchd-dev] Check-in failed?

Dave Zarzycki zarzycki at apple.com
Mon Jun 2 11:06:14 PDT 2008


In Leopard, you code won't be able to checkin unless it vends Mach  
services or Unix sockets.

davez


On Jun 2, 2008, at 4:58 AM, Vyacheslav Karamov wrote:

> Hi All!
>
>
> I'm writing my first launchd-enabled daemon, It works in Tiger, but  
> not
> in Leopard.
> It writes "Check-in failed:" into syslog end exits. Here is my code:
>
> int main (int argc, char * const argv[])
> {
>    signal(SIGTERM, SigtermHandler);
>    signal(SIGINT,  SigtermHandler);
>    /*
>     * Create a new ASL log
>     *
>     */
>    g_asl = asl_open("AudioServer", "Daemon", ASL_OPT_STDERR);
>    log_msg = asl_new(ASL_TYPE_MSG);
>    asl_set(log_msg, ASL_KEY_SENDER, "AudioServer");
>    asl_set_filter(g_asl, ASL_FILTER_MASK_UPTO(ASL_LEVEL_INFO));
>
>    /*
>     * Register ourselves with launchd.
>     *
>     */
>    launch_data_t checkin_request =
> launch_data_new_string(LAUNCH_KEY_CHECKIN);
>    if ( checkin_request == NULL )
>    {
>        asl_log(g_asl, log_msg, ASL_LEVEL_ERR,
> "launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create
> string.");
>        return EXIT_FAILURE;
>    }
>
>    launch_data_t checkin_response = launch_msg(checkin_request);
>    if ( checkin_response == NULL )
>    {
>        asl_log(g_asl, log_msg, ASL_LEVEL_ERR, "launch_msg(\""
> LAUNCH_KEY_CHECKIN "\") IPC failure: %m");
>        return EXIT_FAILURE;
>    }
>
>    if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response))
>    {
>        errno = launch_data_get_errno(checkin_response);
>        asl_log(g_asl, log_msg, ASL_LEVEL_ERR, "Check-in failed: %m");
>        return EXIT_FAILURE;
>    }
> ....
> }
>
> $ cat  /Library/LaunchDaemons/com.circle.AudioServer.Debug.plist:
>
>  <?xml version="1.0" encoding="UTF-8" ?>
>  <!DOCTYPE plist/ (View Source for full doctype...)/>
> - <#> <plist version="*1.0*">
> - <#> <dict>
>  <key>Label</key>
>  <string>com.circle.AudioServer</string>
>  <key>OnDemand</key>
>  <false />
>  <key>ProgramArguments</key>
> - <#> <array>
>
> <string>/Users/slava/Projects/AudioServer/build/Debug/AudioServer</ 
> string>
>  </array>
>  <key>RunAtLoad</key>
>  <true />
>  <key>ServiceIPC</key>
>  <true />
> </dict>
> </plist>
>
> Both binary and property list have  root:wheel 755 permissions
>
>
>
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev



More information about the launchd-dev mailing list