Rasty Rasty - 1 year ago 382
Linux Question

C++: undefined reference to `sd_notify'

I'm new with C++. My problem is that I have a process which creates a lot of processes, I want to identify(get the pid) of one of the children. Looping through children would take a lot of resources(don't ask why). SO I'm trying to get the pid of process by (somehow) identifying if it uses

and get the pid(I don't really now if its possible). I'm using ubuntu 14.04 and created little test program:

#include <systemd/sd-daemon.h>
#include <stdio.h>

int main()
int a;
a = sd_notify(0, "READY=1");
printf("%d -> \n", a);

But it gives me error saying
undefined reference to 'sd_notify'

I found that
is for systemd systems. What is the equivalent of this in upstart systems? Or how can I make sure that the process I'm searching doen't use this function? Or is it possible to log all the messages that is send by processes using

Answer Source

Try installing libsystemd-daemon-devel and then compile using

g++ -o sig sig.cpp -lsystemd-daemon

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download