Bye from forks sends signals?
Hey! Is this newsletter alive?:) Disclaimer: I'm not very familiar with system programming and POSIX 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) Basically, the main process sets up a server and waiting for a message and the child process simply waits for a bit and exits with `bye`. The `errno` is 4 (which is signal interrupt as i understand). The waiting in the child process is important because if it exits before zeromq code, everything's fine and the server is patiently waiting. My assumption here is that `bye` throws some signal? Why else would it affect zeromq in the parent process? Just looking for some explanation. Maybe even the proper way to resolve this. 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? Weird. Can anyone confirm that's what I'm seeing? P.S. completely offtopic but since I'm here. I just noticed that semicolons aren't treated as comments. Why? Can it be enabled? Otherwise my Emacs' lisp-mode comment/uncomment function is useless and no comment highlight either. -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Bye from forks sends signals?
Hey! Is this newsletter alive?:) Disclaimer: I'm not very familiar with system programming and POSIX 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) Basically, the main process sets up a server and waiting for a message and the child process simply waits for a bit and exits with `bye`. The `errno` is 4 (which is signal interrupt as i understand). The waiting in the child process is important because if it exits before zeromq code, everything's fine and the server is patiently waiting. My assumption here is that `bye` throws some signal? Why else would it affect zeromq in the parent process? Just looking for some explanation. Maybe even the proper way to resolve this. 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? Weird. Can anyone confirm that's what I'm seeing? P.S. completely offtopic but since I'm here. I just noticed that semicolons aren't treated as comments. Why? Can it be enabled? Otherwise my Emacs' lisp-mode comment/uncomment function is useless and no comment highlight either. -- 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