<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 09 Jan 2015, at 10:55, <a href="mailto:squeak-dev-request@lists.squeakfoundation.org" class="">squeak-dev-request@lists.squeakfoundation.org</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Date: Fri, 9 Jan 2015 10:55:22 +0100</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">From: Henrik Johansen &lt;</span><a href="mailto:henrik.s.johansen@veloxit.no" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">henrik.s.johansen@veloxit.no</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&gt;</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Subject: Re: [squeak-dev] Re: [Vm-dev] [OSProcess] forking and file</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span class="Apple-tab-span" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">        </span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">descriptors</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">On 09 Jan 2015, at 10:44 , Max Leske &lt;<a href="mailto:maxleske@gmail.com" class="">maxleske@gmail.com</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 09 Jan 2015, at 10:25,<span class="Apple-converted-space">&nbsp;</span><a href="mailto:vm-dev-request@lists.squeakfoundation.org" class="">vm-dev-request@lists.squeakfoundation.org</a><span class="Apple-converted-space">&nbsp;</span>&lt;<a href="mailto:vm-dev-request@lists.squeakfoundation.org" class="">mailto:vm-dev-request@lists.squeakfoundation.org</a>&gt; wrote:<br class=""><br class="">Date: Fri, 9 Jan 2015 10:24:42 +0100<br class="">From: Henrik Johansen &lt;<a href="mailto:henrik.s.johansen@veloxit.no" class="">henrik.s.johansen@veloxit.no</a><span class="Apple-converted-space">&nbsp;</span>&lt;<a href="mailto:henrik.s.johansen@veloxit.no" class="">mailto:henrik.s.johansen@veloxit.no</a>&gt;&gt;<br class="">Subject: Re: [squeak-dev] [Vm-dev] [OSProcess] forking and file<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>descriptors<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 09 Jan 2015, at 9:32 , Max Leske &lt;<a href="mailto:maxleske@gmail.com" class="">maxleske@gmail.com</a><span class="Apple-converted-space">&nbsp;</span>&lt;<a href="mailto:maxleske@gmail.com" class="">mailto:maxleske@gmail.com</a>&gt;&gt; wrote:<br class=""><br class=""><br class=""></blockquote><br class=""><blockquote type="cite" class="">That would mean that I must not close any sockets in the child. One option, it seems to me, is to suspend all processes that use sockets. Terminating them might pose another problem, if socket destruction is part of an unwind block in one of the processes (e.g. TCP connections in Seaside) then sockets will be destroyed during termination.<br class=""><br class="">Another option: set all the socket handles to nil, then terminate the processes (yes ugly, but it might just work…).<br class=""></blockquote><br class="">Just beware you might run into the issue that resuming a processes waiting for a semaphore will proceed as if the semaphore were signalled,<br class="">Can't tell offhand if that would actually be a problem in this case, or if the affected processes would promptly resume waiting after socket read/writes may initiate with no data.<br class=""></blockquote><br class="">I wouldn’t resume any of those processes if I can help it. After creating the segment the child kills itself. Thanks for pointing that out though.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I was thinking you'd need to suspend the processes in the parent, before forking off a child, (to ensure there will be no possibility of a process running before it's suspended in the child) then resume after forking?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>I’m hoping that I can get around that by using #valueUninterruptibly (or similar). It would be much nicer to leave the parent as it is and do everything related to the snapshot in the child. But maybe I’ll have to suspend the processes in the parent in the end.</div><br class=""><blockquote type="cite" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class=""><br class="">Another (probably non-portable, which would be painful if not consistent across platforms) option:<span class="Apple-converted-space">&nbsp;</span><br class="">Forget about image-side handling, and alter the SocketPlugin to set FD_CLOEXEC if available when opening sockets. (It's in<span class="Apple-converted-space">&nbsp;</span><a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html" class="">http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html</a>&lt;<a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html" class="">http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html</a>&gt; , but that's rather new)<span class="Apple-converted-space">&nbsp;</span><br class="">On newer Linuxen, you also have SOCK_CLOEXEC for socket(), which opens/sets in an atomic operation, but the race condition avoided by that is hardly relevant in our case.<br class=""></blockquote><br class="">True. But I really don’t want to maintain a branch of OSProcess :)<br class=""></blockquote><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">It wouldn't be a branch of OSProcess, but an update to the platform SocketPlugin sources.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I was probably wrong and it's not so new (wouldn't it be nice if all API's had the same structure as Postgres, where checking previous versions is *really* easy?), the 2004 version of the standard also includes it. A cursory check indicates at least OSX/*BSD/*Solaris would support it as well.<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Doing the equivalent on Windows seems to have certain caveats though...<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://stackoverflow.com/questions/12058911/can-tcp-socket-handles-be-set-not-inheritable" class="">http://stackoverflow.com/questions/12058911/can-tcp-socket-handles-be-set-not-inheritable</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></blockquote><div><br class=""></div><div>I’m not entirely sure that what you are suggesting will work, at least not with FD_CLOEXEC. man fcntl says:</div><div><br class=""></div><div>File descriptor flags<div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;The following commands manipulate the flags associated with a file</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;descriptor. &nbsp;Currently, only one such flag is defined:&nbsp;</div>FD_CLOEXEC<div class="">,</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;the close-on-exec flag. &nbsp;If the&nbsp;</div>FD_CLOEXEC&nbsp;<div class="">bit is 0, the file</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;descriptor will remain open across an&nbsp;</div>execve(2)<div class="">, otherwise it will be</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;closed.</div><div class=""><br class=""></div><div class="">IIRC fork doesn’t use exec, so this flag doesn’t change anything for my scenario. [1] seems to confirm this.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Max</div><div class=""><br class=""></div><div class="">[1]&nbsp;<a href="http://stackoverflow.com/questions/5713242/linux-fork-prevent-file-descriptors-inheritance" class="">http://stackoverflow.com/questions/5713242/linux-fork-prevent-file-descriptors-inheritance</a></div></div><br class=""><blockquote type="cite" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Cheers,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Henry</span></blockquote></div><br class=""></body></html>