Okay so I built this nice little IPC mechanism that works okay on mac. But on windows, I'm stuck without SIGUSR1. So now what the heck can I do? I don't want to use windows' sendmessage api because I'm using GTK for my GUI.
Can I just use SIGTERM or something and catch it in the same regard?
code:
[code]
static void ipc_recv(int i)
{
load(db_path.c_str(), 0, false);
refresh_gl_viewport();
}
void ipc_init()
{
string cdir = config_dir();
db_path = cdir + "/dropbox.xdf";
sig_path = cdir + "/sig";
signal(SIGUSR1, ipc_recv);
ofstream out(sig_path.c_str());
out << getpid() << endl;
out.close();
}
void ipc_send()
{
save(db_path);
if(kill(accu_pid, SIGUSR1) == -1)
perror("");
}
[/code]
If you are using C++, maybe you can do the trick with try/catch
If you are using C, you can emulate that with setjmp and longjmp
Or I misunderstood the question.
personally I don't know why you aren't using sockets or pipes.
Sockets cause an annoying popup regarding windows defender, the annoying block/unblock dialog. afaik this is right after calling WSAinit.
Pipes block until the both sides open them.
I need a single unidirectional signal to go from one process to the other.
Pipes block until the both sides open them.
No they don't. That's the whole point of the overlapped I/O stuff.
Wow. this really turned out to be a giant pain in the ass.
Unix solution: less than 10 lines
Windows: not so lucky
This is the only way I could do it without a loop requiring me to continuously poll the status of something whether it be a socket or pipe (I hate doing that).
This is quite ridiculous, but at least I can tuck it away and know that my app will do no processing on behalf of IPC unless the message window gets an event.