mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 09:42:19 +00:00
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
This commit is contained in:
parent
282b682cab
commit
4e239a6632
2 changed files with 15 additions and 2 deletions
|
@ -610,10 +610,16 @@ on_pad_added (GstElement * element, GstPad * pad, GstElement * pipeline)
|
||||||
g_signal_connect (pad, "unlinked", (GCallback) on_pad_unlinked, pipeline);
|
g_signal_connect (pad, "unlinked", (GCallback) on_pad_unlinked, pipeline);
|
||||||
|
|
||||||
if (create_sockets) {
|
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));
|
fprintf (stderr, "Error creating sockets: %s\n", strerror (errno));
|
||||||
exit (1);
|
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],
|
g_object_set (ipcpipelinesink, "fdin", sockets[0], "fdout", sockets[0],
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
|
@ -159,10 +159,17 @@ main (int argc, char **argv)
|
||||||
int sockets[2];
|
int sockets[2];
|
||||||
pid_t pid;
|
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));
|
fprintf (stderr, "Error creating sockets: %s\n", strerror (errno));
|
||||||
return 1;
|
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 ();
|
pid = fork ();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
fprintf (stderr, "Error forking: %s\n", strerror (errno));
|
fprintf (stderr, "Error forking: %s\n", strerror (errno));
|
||||||
|
|
Loading…
Reference in a new issue