diff --git a/fairmq/tools/Network.cxx b/fairmq/tools/Network.cxx index 7922f2c9..8d37d7a2 100644 --- a/fairmq/tools/Network.cxx +++ b/fairmq/tools/Network.cxx @@ -99,7 +99,7 @@ string getDefaultRouteNetworkInterface() string interfaceName; #ifdef __APPLE__ // MacOS - unique_ptr file( + unique_ptr file( popen("route -n get default | grep interface | cut -d \":\" -f 2", "r"), pclose); #else // Linux ifstream is("/proc/net/route"); @@ -128,7 +128,7 @@ string getDefaultRouteNetworkInterface() LOG(debug) << "could not get network interface of the default route from /proc/net/route, " "going to try via 'ip route'"; - unique_ptr file( + unique_ptr file( popen("ip route | grep default | cut -d \" \" -f 5 | head -n 1", "r"), pclose); #endif