Re: Bye from forks sends signals?
Dmitry Non Move to real time with the IRC channel: https://picolisp-explored.com/how-to-join-the-picolisp-community https://libera.irclog.whitequark.org/picolisp/2024-01-10 On Tue, 9 Jan 2024 at 19:14, Dmitry Non wrote: > Hey. > > That's awesome. Thank you very much, Alex! > > > On 6 Jan 2024, at 06:48, Alexander Burger > wrote: > > > > Hi Dmitry, > > > >> Is this newsletter alive?:) > > > > Yes, just not so noisy :) > > > > > >> I'm playing around with `native` and ZeroMQ and found a curious > behaviour. > >> > >>(unless (fork) > >> (wait 2000) > >> (bye)) > >> > >>(setq Context (native "libzmq.so" "zmq_ctx_new" 'P)) > >>(setq ZMQ_REP 4) > >>(setq Socket (native "libzmq.so" "zmq_socket" 'P Context ZMQ_REP)) > >>(native "libzmq.so" "zmq_bind" 'I Socket "tcp://*:") > >> > >>(buf > >> Buffer 10 > >> (prinl "Waiting for messages") > >> (when (= -1 (native "libzmq.so" "zmq_recv" 'I Socket Buffer 10 0)) > >> (prinl (pack "Error: " (errno) > > > > This looks good. > > > > > >> The `errno` is 4 (which is signal interrupt as i understand). > > > > Yes. EINTR is 4 on most systems. You can see it with > > > > : (sysdefs "errno") > > -> EACCES > > : EINTR > > -> 4 > > > > or (vi "@lib/sysdefs"). > > > > > >> My assumption here is that `bye` throws some signal? Why else would it > affect > >> zeromq in the parent process? > >> Actually, while writing this I found out about SIGCHLD which is > apparently > >> sent to parent on child's exit so I guess zmq_recv gets interrupted by > that > >> for some reason? > > > > Absolutely correct. The child sends a SIGCHLD signal, which must be > handled or > > ignored. > > > > I don't have libzmq at the moment and cannot test it, but I think it > should be > > something like > > > > (while (lt0 (native "libzmq.so" "zmq_recv" 'I Socket Buffer 10 0)) > > (unless (== EINTR (errno)) > > (quit (errno) "Signal") ) ) > > > > > >> P.S. completely offtopic but since I'm here. I just noticed that > semicolons > >> aren't treated as comments. Why? > > > > Comments in PicoLisp are # or #{...}#. > > > > > >> Can it be enabled? Otherwise my Emacs' lisp-mode comment/uncomment > function is > >> useless and no comment highlight either. > > > > There is no built-in way to change it. There are some Emacs libs for > PicoLisp, > > but I don't use Emacs and cannot be helpful here. > > > > ☺/ A!ex > > > > -- > > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe > > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe >
Re: Bye from forks sends signals?
Hey. That's awesome. Thank you very much, Alex! > On 6 Jan 2024, at 06:48, Alexander Burger wrote: > > Hi Dmitry, > >> Is this newsletter alive?:) > > Yes, just not so noisy :) > > >> I'm playing around with `native` and ZeroMQ and found a curious behaviour. >> >>(unless (fork) >> (wait 2000) >> (bye)) >> >>(setq Context (native "libzmq.so" "zmq_ctx_new" 'P)) >>(setq ZMQ_REP 4) >>(setq Socket (native "libzmq.so" "zmq_socket" 'P Context ZMQ_REP)) >>(native "libzmq.so" "zmq_bind" 'I Socket "tcp://*:") >> >>(buf >> Buffer 10 >> (prinl "Waiting for messages") >> (when (= -1 (native "libzmq.so" "zmq_recv" 'I Socket Buffer 10 0)) >> (prinl (pack "Error: " (errno) > > This looks good. > > >> The `errno` is 4 (which is signal interrupt as i understand). > > Yes. EINTR is 4 on most systems. You can see it with > > : (sysdefs "errno") > -> EACCES > : EINTR > -> 4 > > or (vi "@lib/sysdefs"). > > >> My assumption here is that `bye` throws some signal? Why else would it affect >> zeromq in the parent process? >> Actually, while writing this I found out about SIGCHLD which is apparently >> sent to parent on child's exit so I guess zmq_recv gets interrupted by that >> for some reason? > > Absolutely correct. The child sends a SIGCHLD signal, which must be handled or > ignored. > > I don't have libzmq at the moment and cannot test it, but I think it should be > something like > > (while (lt0 (native "libzmq.so" "zmq_recv" 'I Socket Buffer 10 0)) > (unless (== EINTR (errno)) > (quit (errno) "Signal") ) ) > > >> P.S. completely offtopic but since I'm here. I just noticed that semicolons >> aren't treated as comments. Why? > > Comments in PicoLisp are # or #{...}#. > > >> Can it be enabled? Otherwise my Emacs' lisp-mode comment/uncomment function >> is >> useless and no comment highlight either. > > There is no built-in way to change it. There are some Emacs libs for PicoLisp, > but I don't use Emacs and cannot be helpful here. > > ☺/ A!ex > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Bye from forks sends signals?
Hi Dmitry, > Is this newsletter alive?:) Yes, just not so noisy :) > I'm playing around with `native` and ZeroMQ and found a curious behaviour. > > (unless (fork) > (wait 2000) > (bye)) > > (setq Context (native "libzmq.so" "zmq_ctx_new" 'P)) > (setq ZMQ_REP 4) > (setq Socket (native "libzmq.so" "zmq_socket" 'P Context ZMQ_REP)) > (native "libzmq.so" "zmq_bind" 'I Socket "tcp://*:") > > (buf > Buffer 10 > (prinl "Waiting for messages") > (when (= -1 (native "libzmq.so" "zmq_recv" 'I Socket Buffer 10 0)) >(prinl (pack "Error: " (errno) This looks good. > The `errno` is 4 (which is signal interrupt as i understand). Yes. EINTR is 4 on most systems. You can see it with : (sysdefs "errno") -> EACCES : EINTR -> 4 or (vi "@lib/sysdefs"). > My assumption here is that `bye` throws some signal? Why else would it affect > zeromq in the parent process? > Actually, while writing this I found out about SIGCHLD which is apparently > sent to parent on child's exit so I guess zmq_recv gets interrupted by that > for some reason? Absolutely correct. The child sends a SIGCHLD signal, which must be handled or ignored. I don't have libzmq at the moment and cannot test it, but I think it should be something like (while (lt0 (native "libzmq.so" "zmq_recv" 'I Socket Buffer 10 0)) (unless (== EINTR (errno)) (quit (errno) "Signal") ) ) > P.S. completely offtopic but since I'm here. I just noticed that semicolons > aren't treated as comments. Why? Comments in PicoLisp are # or #{...}#. > Can it be enabled? Otherwise my Emacs' lisp-mode comment/uncomment function is > useless and no comment highlight either. There is no built-in way to change it. There are some Emacs libs for PicoLisp, but I don't use Emacs and cannot be helpful here. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe