On Tue, Oct 14, 2008 at 11:06:59AM +0200, Alexander Burger wrote: > wait : 1000 > close : 6 > close = 6 > wait = NIL > 23078 SIG-11
Well, now the situation is clear to me. I would not call it a bug in the PicoLisp kernel, though crashing with a segmentation violation when accessing a closed file is a rather unfriendly behavior. 'server' installs a background task on the socket after a client connected: (task *Sock (http @)) Then the loop executes (loop (prinl "Content-Type: text/plain^M") ... (NIL (flush)) (wait 1000) ) ) During the 'wait' (i.e. the main event loop) the client closes the connection, causing the body (http @) above to wake up. 'http' receives EOF, closes the socket and uninstalls the task. Our loop above does not know that, and merrily continues to print to that closed socket, causing the crash. So it is basically not a good idea to have a background task meddling with the very same socket we are using in the main loop. To avoid this, we could uninstall the task before calling the main loop: (task *Sock) (loop (prinl "Content-Type: text/plain^M") This is IMHO the best solution. Other possibilites are avoiding to call 'wait', using, as already mentioned (call 'sleep 1), or at least temporarily switching off all background tasks during 'wait': (let *Run NIL (wait 1000) ) ) ) or at least that single task running on the socket: (let *Run (delete (assoc *Sock *Run) *Run) (wait 1000) ) ) ) Cheers, - Alex -- UNSUBSCRIBE: mailto:[EMAIL PROTECTED]