Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added 3.0 test version

  • Loading branch information...
commit 9a579f66309f14376b15518180884d8ed492431c 1 parent 0719246
@hintjens hintjens authored
Showing with 70 additions and 0 deletions.
  1. +5 −0 218/3-0/.gitignore
  2. +31 −0 218/3-0/child.c
  3. +34 −0 218/3-0/parent.c
View
5 218/3-0/.gitignore
@@ -0,0 +1,5 @@
+core
+*.o
+parent
+child
+
View
31 218/3-0/child.c
@@ -0,0 +1,31 @@
+// Child test, run from within parent
+
+#include "zmq.h"
+#include "assert.h"
+#include "stdint.h"
+#include "stdio.h"
+#include "unistd.h"
+
+int main ()
+{
+ void *ctx = zmq_init (1);
+ assert (ctx);
+
+ void *dealer = zmq_socket (ctx, ZMQ_DEALER);
+ assert (dealer);
+ int rc = zmq_connect (dealer, "tcp://localhost:2211");
+ assert (rc == 0);
+
+ while (1) {
+ // Send signal to parent
+ zmq_msg_t msg;
+ zmq_msg_init (&msg);
+ zmq_sendmsg (dealer, &msg, 0);
+ zmq_msg_close (&msg);
+
+ // Do some work
+ sleep (1);
+ }
+ return 0;
+}
+
View
34 218/3-0/parent.c
@@ -0,0 +1,34 @@
+// Parent test, run twice in a row to provoke error
+
+#include "zmq.h"
+#include "assert.h"
+#include "stdint.h"
+#include "stdio.h"
+#include "unistd.h"
+
+int main ()
+{
+ void *ctx = zmq_init (1);
+ assert (ctx);
+
+ void *dealer = zmq_socket (ctx, ZMQ_DEALER);
+ assert (dealer);
+ int rc = zmq_bind (dealer, "tcp://*:2211");
+ assert (rc == 0);
+
+ // Start child process
+ pid_t pid = fork();
+ if (pid == 0)
+ execl ("child", "child",NULL);
+
+ zmq_msg_t msg;
+ zmq_msg_init (&msg);
+ zmq_recvmsg (dealer, &msg, 0);
+ zmq_msg_close (&msg);
+
+ int linger = 0;
+ zmq_close (dealer);
+ zmq_term (ctx);
+ return 0;
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.