David T. Lewis: Very useful your explanation. <br><br>Gary: thanks too.<br><br>If fact, I did what you tell we. The problem was that the select() invocation was inside a specific function of OpenDBX. From SqueakDBX the only thing I can do is to call again that function, but this is very different that only call select() function again.<br>

<br>So, what I change openDBX code from this:<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if( ( fd = PQsocket( (PGconn*) handle-&gt;generic ) ) == -1 )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn-&gt;errtype = -1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -ODBX_ERR_BACKEND;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FD_ZERO( &amp;fds );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FD_SET( fd, &amp;fds );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch( select( fd + 1, &amp;fds, NULL, NULL, timeout ) )<br><br><br><br>to<br><br><br>&nbsp;&nbsp;&nbsp; do {<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if( ( fd = PQsocket( (PGconn*) handle-&gt;generic ) ) == -1 )<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn-&gt;errtype = -1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -ODBX_ERR_BACKEND;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FD_ZERO( &amp;fds );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FD_SET( fd, &amp;fds );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rv = select( fd + 1, &amp;fds, NULL, NULL, timeout );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } while ((rv == -1) &amp;&amp; (errno == EINTR)); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch( rv )<br><br><br>And now It works perfect. It was difficult to reproduce because openDBX tests where ok, but squeakDBX ones not. This is because of SqueakVM as you explain me.<br>
<br>So, I am waiting openDBX author feedback about my code, but at least it work!!!<br><br>Thanks for the help again.<br><br>Mariano<br><br><br><div class="gmail_quote">On Mon, Jan 26, 2009 at 8:11 PM, Gary Chambers <span dir="ltr">&lt;<a href="mailto:gazzaguru2@btinternet.com" target="_blank">gazzaguru2@btinternet.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Indeed. We did some work with RS485 support for the Serial plugin... EINTRs happen all the time... recommended to retry (see Linux documentation around the web as to why). Obviously, in a plugin, the retry can happen quite quickly. Not sure how using FFI might respond.<br>


<br>
Regards, Gary.<br>
<br>
----- Original Message ----- From: &quot;David T. Lewis&quot; &lt;<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>&gt;<br>
To: &quot;The general-purpose Squeak developers list&quot; &lt;<a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a>&gt;<br>
Sent: Monday, January 26, 2009 1:50 AM<br>
Subject: Re: [squeak-dev] Help needed with select() socket function and signalhandlers in squeakVM<div><div></div><div><br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sun, Jan 25, 2009 at 08:50:35PM -0200, Mariano Martinez Peck wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Now, I have a problem with select() invocation. This function returns -1.<br>
And the printf of the errno (where select() stores the errors), says: &quot;Error<br>
with select function: Interrupted system call&quot; which means I am getting a<br>
EINTR error. If you see console, you can see something like this:<br>
<br>
timeval tv_usec value: 0<br>
timeval tv_sec value: 3<br>
timeval tv_usec value: 0<br>
timeval tv_sec value: 2<br>
timeval tv_usec value: 996000<br>
timeval tv_sec value: 3<br>
timeval tv_usec value: 0<br>
Error with select function: Interrupted system call<br>
<br>
<br>
I asked Norbert (openDBX author) and he tell me exactly this:<br>
<br>
&quot;An interrupted system call is something very normal because signals can be<br>
sent<br>
at every time to the application, either by the system or by the user. I<br>
guess, in the Squeak code there is some signal handler installed, which does<br>
something if one of the defined signals arrive.<br>
<br>
What I will do is to hide the consequences (returning an error) by looking<br>
at<br>
the error value and reenter the select call if the system call is<br>
interrupted.&quot;<br>
</blockquote>
<br>
Norbert is correct, and his solution of reentering the system call sounds<br>
like the right thing to do.<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
All I know is squeakVM is written it SLANG and then that&#39;s transformed to C.<br>
So, squeakVM runs in C. So, there is where it can be a signal handler ? Is<br>
there some way to change that from squeak (image) ?<br>
</blockquote>
<br>
Any interrupt handler will service interrupts for the entire VM, so this is<br>
not something that you would want to set up for a specific plugin. If one<br>
plugin sets a signal handler, it affects all other plugins as well as the<br>
VM itself.<br>
<br>
It is actually quite easy to experiment with setting signal handlers if<br>
you are using a Unix VM and if you have OSProcess installed. For example,<br>
if you want to handle the SIGQUIT signal, you can evualate the expression<br>
&#39;OSProcess accessor forwardSigQuit&#39; to get a Smalltalk semaphore that will be<br>
signalled each time the operating system sends a SIGQUIT (signal number 3)<br>
to the VM. You can have a Squeak process that waits on the semaphore and does<br>
whatever you like.<br>
<br>
To be clear however, Norbert&#39;s explanation is correct regardless of how<br>
the VM chooses to handle a signal. When a system call such as select is<br>
interrupted, the application (your plugin) needs to check for this and<br>
retry the system call.<br>
<br>
HTH,<br>
<br>
Dave<br>
<br>
<br>
</blockquote>
<br>
<br>
</div></div></blockquote></div><br>