Heinrich, Am 14.03.2014 um 11:42 schrieb Heinrich Hartmann <[email protected]>:
> Just a comment on the side: > > Unix pipes and ZeroMQ sockets are indeed a neat mix. Have a look at > the examples here > * https://github.com/HeinrichHartmann/zmqdump#examples > * https://twitter.com/HeinrichHartman/status/440942775173799936 > > @Michael: Can you comment a bit more on your use case? > Your gist seems related to zmqdump. Maybe you have something better. those are interesting links - not sure how they fit in what I'm doing though; this is what I am after: I have an existing interpreter written in C for a domain-specific language. It has a traditional main loop like so: while (!eof) { readline(); parse_and_execute_line(); } Among others, this interpreter starts other processes into the background, and promptly creates zombie processes because of sloppy signal handling; this is where the sigfd poller code comes in. Now that interpreter is now being beefed up to talk to zeroMQ peers, which suggests replacing that main loop with a zloop - that's where the readline/stdin poller integration helps. I'm retrofitting a whole package with czmq interaction, and that is a recurring pattern: out goes the main loop, in comes the zloop reactor, bingo: communications, signal handling, events all taken care of, synchronous and through callbacks. One-time effort to get right, smooth sailing thereafter. regards Michael > > Best regards, > Heinrich > > On Thu, Mar 13, 2014 at 11:21 PM, Pieter Hintjens <[email protected]> wrote: >> I merged your patch, nice. :) >> >> I'd never thought of using stdin with ZeroMQ sockets, it's a neat mix. >> >> On Thu, Mar 13, 2014 at 10:39 PM, Michael Haberler <[email protected]> >> wrote: >>> >>> Am 13.03.2014 um 22:24 schrieb Pieter Hintjens <[email protected]>: >>> >>>> I think removing the check is fine. If socket=NULL and fd=0 is a valid >>>> combination, the code shouldn't treat it as an error. In any case this >>>> isn't documented behavior in any way, so you are free to change it. >>> >>> >>> thanks, PR sent >>> >>> here is the bonus gist conditional on this patch: using libreadline in >>> zloop >>> >>> https://gist.github.com/mhaberler/9537478 >>> >>> - Michael >>> >>> >>>> On Thu, Mar 13, 2014 at 9:09 PM, Michael Haberler <[email protected]> >>>> wrote: >>>>> trying to use zloop for reading with libreadline on stdin, while handling >>>>> other events >>>>> >>>>> this doesnt work because fd 0 is considered invalid in zloop.c:328 ; if I >>>>> disable the check that works just fine >>>>> >>>>> I see two ways to resolve the situation: >>>>> >>>>> - consider a zmq_pollitem with socket=NULL and fd=0 as valid, to mean: >>>>> poll on fd 0 >>>>> - explicitly set an invalid fd to -1, which is an API change >>>>> >>>>> I would prefer the first option - please advise >>>>> >>>>> - Michael >>>>> >>>>> >>>>> int >>>>> zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void >>>>> *arg) >>>>> { >>>>> assert (self); >>>>> >>>>> // suggestion: remove this test: >>>>> if (!item->socket && !item->fd) >>>>> return -1; >>>>> _______________________________________________ >>>>> zeromq-dev mailing list >>>>> [email protected] >>>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev >>>> _______________________________________________ >>>> zeromq-dev mailing list >>>> [email protected] >>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev >>> >>> _______________________________________________ >>> zeromq-dev mailing list >>> [email protected] >>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> _______________________________________________ >> zeromq-dev mailing list >> [email protected] >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > > > -- > Heinrich Hartmann > > Mobile: +49 1525 363 8134 > Web: heinrich-hartmann.net > Social: Google+ / Facebook > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
