core: Block until netconfig exits on suse.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@@ -130,12 +131,12 @@ netconfig_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static GPid
|
||||||
run_netconfig (GError **error)
|
run_netconfig (GError **error, gint *stdin_fd)
|
||||||
{
|
{
|
||||||
char *argv[5];
|
char *argv[5];
|
||||||
char *tmp;
|
char *tmp;
|
||||||
gint stdin_fd;
|
GPid pid = -1;
|
||||||
|
|
||||||
argv[0] = "/sbin/netconfig";
|
argv[0] = "/sbin/netconfig";
|
||||||
argv[1] = "modify";
|
argv[1] = "modify";
|
||||||
@@ -148,10 +149,10 @@ run_netconfig (GError **error)
|
|||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
|
||||||
if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, netconfig_child_setup,
|
if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, netconfig_child_setup,
|
||||||
NULL, NULL, &stdin_fd, NULL, NULL, error))
|
NULL, &pid, &stdin_fd, NULL, NULL, error))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return stdin_fd;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -173,11 +174,13 @@ dispatch_netconfig (const char *domain,
|
|||||||
const char *iface,
|
const char *iface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint fd;
|
|
||||||
char *str;
|
char *str;
|
||||||
|
GPid pid;
|
||||||
|
gint fd;
|
||||||
|
int ret;
|
||||||
|
|
||||||
fd = run_netconfig (error);
|
pid = run_netconfig (error, &fd);
|
||||||
if (fd < 0)
|
if (pid < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
write_to_netconfig (fd, "INTERFACE", iface);
|
write_to_netconfig (fd, "INTERFACE", iface);
|
||||||
@@ -205,7 +208,15 @@ dispatch_netconfig (const char *domain,
|
|||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
return TRUE;
|
/* Wait until the process exits */
|
||||||
|
|
||||||
|
again:
|
||||||
|
|
||||||
|
ret = waitpid (pid, NULL, 0);
|
||||||
|
if (ret < 0 && errno == EINTR)
|
||||||
|
goto again;
|
||||||
|
|
||||||
|
return ret > 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user