[arch-general] Get netctl status from C?

Martti Kühne mysatyre at gmail.com
Sun Dec 15 06:45:11 EST 2013

On Sun, Dec 15, 2013 at 12:32 PM, Martti Kühne <mysatyre at gmail.com> wrote:
> I think there isn't explicitly any process running after netctl is
> done configuring the network configuration. So you should either get
> more specific about the kind of information you want, so whether you
> are talking about network state or netctl's opinion about it (not that
> these are likely to diverge, but there's my point)...
> Uhm... a glance into netctl's source just revealed it's a bash script.
> You'll need exec anyway.

wait. so:

char *statefile = getenv("NETCTL_STATE_FILE");
FILE *f;
  statefile = "/var/lib/netctl/netctl.state"; // from /usr/lib/network/globals
f = fopen(statefile, "r");
if(f) {
  // parse whatever you find there...

I think the point in running netctl is that running it would update
said state file. So, the state file might be there and all. That's how
I believe these diverge. You'd have to analyze what netctl does there
and replicate that in c, but ... no really, use exec().


More information about the arch-general mailing list