Commit 4e239a66 authored by George Kiagiadakis's avatar George Kiagiadakis

examples: ipcpipeline: do not use the linux-specific SOCK_NONBLOCK flag

Use fcntl() instead to set O_NONBLOCK, which is portable.

https://bugzilla.gnome.org/show_bug.cgi?id=786763
parent 282b682c
......@@ -610,10 +610,16 @@ on_pad_added (GstElement * element, GstPad * pad, GstElement * pipeline)
g_signal_connect (pad, "unlinked", (GCallback) on_pad_unlinked, pipeline);
if (create_sockets) {
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, sockets)) {
if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockets)) {
fprintf (stderr, "Error creating sockets: %s\n", strerror (errno));
exit (1);
}
if (fcntl (sockets[0], F_SETFL, O_NONBLOCK) < 0 ||
fcntl (sockets[1], F_SETFL, O_NONBLOCK) < 0) {
fprintf (stderr, "Error setting O_NONBLOCK on sockets: %s\n",
strerror (errno));
exit (1);
}
g_object_set (ipcpipelinesink, "fdin", sockets[0], "fdout", sockets[0],
NULL);
......
......@@ -159,10 +159,17 @@ main (int argc, char **argv)
int sockets[2];
pid_t pid;
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, sockets) < 0) {
if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockets)) {
fprintf (stderr, "Error creating sockets: %s\n", strerror (errno));
return 1;
}
if (fcntl (sockets[0], F_SETFL, O_NONBLOCK) < 0 ||
fcntl (sockets[1], F_SETFL, O_NONBLOCK) < 0) {
fprintf (stderr, "Error setting O_NONBLOCK on sockets: %s\n",
strerror (errno));
return 1;
}
pid = fork ();
if (pid < 0) {
fprintf (stderr, "Error forking: %s\n", strerror (errno));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment