mcedit problem (2)

Björn Eriksson mdeans at algonet.se
Mon Dec 17 18:46:07 UTC 2001


 [Please excuse my editing]

On Mon, Dec 17, 2001 at 10:33:13AM +0200, Andrew V. Samoilov wrote:
> >is the following problem known? Sometimes (usually a few times a day :-(
> >) if I press F4 to edit a .cc file with the internal editor, the
> >Midnight Commander hangs up. Here is the description of the problem:
> >
> >---
> >404         for (;;) {
> >405             c = fgetc (f);
> >406             if (c == EOF) {
> >407                 if (errno == EINTR)
> >408                     continue;
> >---
> 
> I cannot reproduce this, but it is possible if previous system call was 
> interrupted.
> fgetc returns -1 on error and on end of file, so additional check needed.

 I've also tried to reproduce this w/o success. I think we need to call
clearerr(_unlocked?) on line 408 above. (If found some usenet posts that
indicated that this is indeed necessary on Solaris. (Sorry, I that was
last week and I didn't save them.))

 [I've done OS-/embedded-stuff all my life so I'm not very good at
user-space things.]

 Some quotes from libc.info:

   Error Recovery

   ...big snip...

      Most errors that can happen are not recoverable -- a second try will
   always fail again in the same way. So usually it is best to give up and
   report the error to the user, rather than install complicated recovery
   logic.

   ...small snip...

      One important exception is `EINTR' ( Interrupted Primitives). Many
   stream I/O implementations will treat it as an ordinary error, which
   can be quite inconvenient. You can avoid this hassle by installing all
   signals with the `SA_RESTART' flag.

> Does patch below help you?

> --- syntax.c	Wed Nov 28 17:17:37 2001
> +++ syntax.c-1.19+	Mon Dec 17 10:09:15 2001
> @@ -405,6 +405,8 @@ static int read_one_line (char **line, F
>      for (;;) {
>  	c = fgetc (f);
>  	if (c == EOF) {
> +	    if (feof (f))
> +		break;
>  	    if (errno == EINTR)
>  		continue;
>  	    r = 0;

 I don't think so but either way we need some code up that can test it
(EINTR), perhaps a timer?


-- 
//Björnen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20011217/e757bbcb/attachment.asc>


More information about the mc-devel mailing list