Network change registration error in MAC OS X 10.7 (Lion)

I tried to register the network_change event in MAC OS X 10.7 (lion) with the following code:

#define kNotifySCNetworkChange "com.apple.system.config.network_change"
void init()
{

   status = notify_register_check(kNotifySCNetworkChange, &token);
   if (status != NOTIFY_STATUS_OK)
   {
       cout << "Event Registration failed" <<endl;
   }
   cout << "Event Registration Success" << endl;

}

.....

If I use this code in a sample program, it is successfully registered. If I use this in my application, the notify_register_check () function returns with a status of 1,000,000 (NOTIFY_STATUS_FAILED). In addition, the errno return value is 0.

Note. My application works in Leopard and Snow Leopard without any problems (registration success)

I searched for this status, but could not find the relevant information. Can someone tell me when this NOTIFY_STATUS_FAILED is returned?


, : fork() . , Parent Process. . Child Process??? !!!

+3
1

errno 0, API , API Mach. mach_error() . ( mach, ). , Mountain Lion:

#include <notify.h>
#include <iostream>

#define kNotifySCNetworkChange "com.apple.system.config.network_change"

void init()
{

   int token;
   int status = notify_register_check(kNotifySCNetworkChange, &token);
   if (status != NOTIFY_STATUS_OK)
   {
       std::cout << "Event Registration failed" <<std::endl;
   }
   std::cout << "Event Registration Success" << std::endl;

}

int main()
{
 int rc = fork();
 init();


}
0

All Articles