i having strange problem c zeromq on os x. using "multithreaded service in c" code guide , have added call system("ls") after sleep(1) call in worker_routine function. function looks this:
static void * worker_routine (void *context) { // socket talk dispatcher void *receiver = zmq_socket (context, zmq_rep); zmq_connect (receiver, "inproc://workers"); while (1) { char *string = s_recv (receiver); printf ("received request: [%s]\n", string); free (string); // 'work' sleep (1); system("ls"); // send reply client s_send (receiver, "world"); } zmq_close (receiver); return null; } when connect server sample client in guide, ls runs s_send fails noent error , no more requests handled. if remove system("ls") call works fine.
does know might going on?
thanks, steve
system not thread-safe. see sample implementation in posix understanding of why it's not , can't be:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html
in particular, changes signal dispositions, process-global resource.
it's possible output of ls going somewhere causes problem. intend output go? replacement system popen, allows read output of command , process or send wherever want.
Comments
Post a Comment