unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Can't interrupt directory_files_internal run from timer-event-handler
@ 2005-08-05  9:03 Klaus Zeitler
  2005-08-05 20:38 ` Richard M. Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Klaus Zeitler @ 2005-08-05  9:03 UTC (permalink / raw)


The following problem occurs with CVS emacs + ECB under Solaris 5.8.

While ECB performs its stealth update activities, emacs sometimes seems to
hang for a long time.
gdb shows the following function and backtrace:

directory_files_internal (directory=16076323, full=3313665, match=3313665, 
    nosort=3313713, attrs=0, id_format=3313665)
    at /vol/freeware/cvs/emacs/head/emacs/src/dired.c:226
226           if (dp == NULL && errno == EAGAIN)
(gdb) p directory
$1 = 16076323
(gdb) pr
"/vol/cld_scratch"

(gdb) xbacktrace
 "directory-files"
 "apply"
 "ecb-directory-files"
 "ecb-check-emptyness-of-dir"
 "ecb-stealthy-empty-dir-check"
 "ecb-stealthy-updates"
 "apply"
 "byte-code"
 "timer-event-handler"

I think emacs waits for readdir in dired.c:223 to complete and unfortunately
C-g doesn't work during stealthy update.

The culprit BTW is a mount point to a VAX cluster that e.g. need 20 minutes
to return from 'M-x eval-expression (directory-files "/vol/cld_scratch")'.
While I can interrupt 'M-x eval-expression (directory-files "/vol/cld_scratch")'
with C-g just fine, C-g has no effect when this command is run from 
timer-event-handler.

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
|  Email:             kzeitler@lucent.com  |
 ------------------------------------------
---
The only problem with being a man of leisure
is that you can never stop and take a rest.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-05  9:03 Can't interrupt directory_files_internal run from timer-event-handler Klaus Zeitler
@ 2005-08-05 20:38 ` Richard M. Stallman
  2005-08-06  6:57   ` Eli Zaretskii
  2005-08-09 23:07   ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Richard M. Stallman @ 2005-08-05 20:38 UTC (permalink / raw)
  Cc: emacs-devel

Timer code normally turns off C-g so that you won't interrupt it
by accident.  (After all, you can't predict when the timer code
will be running.)  If ECB is going to do something potentially
slow from a timer, it should probably bind inhibit-quit to nil
around that code, after displaying a message in the echo area
to inform the user what is happening.

Alternatively, it could use start-process to run ls asychronously
as a way to find out whether the directory is empty.  The process
sentinel could take action based on whether the output was empty.
Then you wouldn't have any such problem.
I suggest forwarding this to the ECB developers.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-05 20:38 ` Richard M. Stallman
@ 2005-08-06  6:57   ` Eli Zaretskii
  2005-08-07 17:15     ` Richard M. Stallman
  2005-08-09 23:15     ` Stefan Monnier
  2005-08-09 23:07   ` Stefan Monnier
  1 sibling, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2005-08-06  6:57 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

> From: "Richard M. Stallman" <rms@gnu.org>
> Date: Fri, 05 Aug 2005 16:38:14 -0400
> Cc: emacs-devel@gnu.org
> 
> Alternatively, it could use start-process to run ls asychronously
> as a way to find out whether the directory is empty.

There's no need to run any program just to know if a directory is
empty.  Emacs has primitives which will tell that directly (e.g.,
file-attributes) and do that faster.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-06  6:57   ` Eli Zaretskii
@ 2005-08-07 17:15     ` Richard M. Stallman
  2005-08-07 18:15       ` Eli Zaretskii
  2005-08-09 23:15     ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Richard M. Stallman @ 2005-08-07 17:15 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

    There's no need to run any program just to know if a directory is
    empty.  Emacs has primitives which will tell that directly (e.g.,
    file-attributes) and do that faster.

How do you determine that from file-attributes?  It is not obvious.
You might try to do it from the number of hard links to the directory,
which will normally be 2 for an empty directory, since users normally
can't create alternate names for a directory.  But isn't it possible
for root to create them?  Then an empty directory could have a link count
greater than two.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-07 17:15     ` Richard M. Stallman
@ 2005-08-07 18:15       ` Eli Zaretskii
  2005-08-08  8:44         ` Johan Vromans
  2005-08-09  0:27         ` Richard M. Stallman
  0 siblings, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2005-08-07 18:15 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

> From: "Richard M. Stallman" <rms@gnu.org>
> CC: kzeitler@lucent.com, emacs-devel@gnu.org
> Date: Sun, 07 Aug 2005 13:15:29 -0400
> 
>     There's no need to run any program just to know if a directory is
>     empty.  Emacs has primitives which will tell that directly (e.g.,
>     file-attributes) and do that faster.
> 
> How do you determine that from file-attributes?  It is not obvious.

A combination of file-attributes (looking at the number of links) and
directory-files should do that, I think.

> You might try to do it from the number of hard links to the directory,
> which will normally be 2 for an empty directory, since users normally
> can't create alternate names for a directory.  But isn't it possible
> for root to create them?

I'm not an expert on this, but I think it's impossible to create such
alternate names, since GNU Find uses this fact to detect directories
with no subdirectories.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-07 18:15       ` Eli Zaretskii
@ 2005-08-08  8:44         ` Johan Vromans
  2005-08-08 14:32           ` Johan Vromans
  2005-08-09  0:27         ` Richard M. Stallman
  1 sibling, 1 reply; 12+ messages in thread
From: Johan Vromans @ 2005-08-08  8:44 UTC (permalink / raw)


Eli Zaretskii <eliz@gnu.org> writes:

> I'm not an expert on this, but I think it's impossible to create such
> alternate names, since GNU Find uses this fact to detect directories
> with no subdirectories.

GNU Find also has a command line option to defeat this heuristic,
probably with reason.

-- Johan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-08  8:44         ` Johan Vromans
@ 2005-08-08 14:32           ` Johan Vromans
  0 siblings, 0 replies; 12+ messages in thread
From: Johan Vromans @ 2005-08-08 14:32 UTC (permalink / raw)


Johan Vromans <jvromans@squirrel.nl> writes:

> GNU Find also has a command line option to defeat this heuristic,
> probably with reason.

Sorry, I have to correct this. I got the information from the manual
page for 'find' under the assumption that a GNU/Linux system would
have GNU find. However, it turned out to be the case that my system
(Fedora Core 2) has a different find utility (from the Secure Locate
kit).

-- Johan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-07 18:15       ` Eli Zaretskii
  2005-08-08  8:44         ` Johan Vromans
@ 2005-08-09  0:27         ` Richard M. Stallman
  2005-08-14 20:13           ` Sascha Wilde
  1 sibling, 1 reply; 12+ messages in thread
From: Richard M. Stallman @ 2005-08-09  0:27 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

    A combination of file-attributes (looking at the number of links) and
    directory-files should do that, I think.

But...it is using directory-files now, and that is what causes the
problem.  The question is how to avoid using using directory-files.

    I'm not an expert on this, but I think it's impossible to create such
    alternate names, since GNU Find uses this fact to detect directories
    with no subdirectories.

Linux seems to refuse to do this even if you are root.
But I believe that root could do it on Unix at some point.
Maybe that was only in old versions in the early 80s.

It might be that that case is so peculiar that it can safely be
ignored here.  If so, looking at the link count would be ok.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-05 20:38 ` Richard M. Stallman
  2005-08-06  6:57   ` Eli Zaretskii
@ 2005-08-09 23:07   ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2005-08-09 23:07 UTC (permalink / raw)
  Cc: Klaus Zeitler, emacs-devel

> Timer code normally turns off C-g so that you won't interrupt it
> by accident.  (After all, you can't predict when the timer code
> will be running.)  If ECB is going to do something potentially
> slow from a timer, it should probably bind inhibit-quit to nil
> around that code, after displaying a message in the echo area

Indeed.  Except that just binding inhibit-quit to nil may not quite do
what we want: it should use with-local-quit or something equivalent.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-06  6:57   ` Eli Zaretskii
  2005-08-07 17:15     ` Richard M. Stallman
@ 2005-08-09 23:15     ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2005-08-09 23:15 UTC (permalink / raw)
  Cc: kzeitler, rms, emacs-devel

> There's no need to run any program just to know if a directory is
> empty.  Emacs has primitives which will tell that directly (e.g.,
> file-attributes) and do that faster.

If directory-files blocks (on a failed NFS server), file-attributes is
pretty likely to block just as well, in which case `ls' may be a good way to
do the equivalent of running directory-files asynchronously.


        Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-09  0:27         ` Richard M. Stallman
@ 2005-08-14 20:13           ` Sascha Wilde
  2005-08-15 16:04             ` Richard M. Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Sascha Wilde @ 2005-08-14 20:13 UTC (permalink / raw)
  Cc: kzeitler, Eli Zaretskii, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1222 bytes --]

On Mon, Aug 08, 2005 at 08:27:40PM -0400, Richard M. Stallman wrote:
>     I'm not an expert on this, but I think it's impossible to create such
>     alternate names, since GNU Find uses this fact to detect directories
>     with no subdirectories.
> 
> Linux seems to refuse to do this even if you are root.
> But I believe that root could do it on Unix at some point.
> Maybe that was only in old versions in the early 80s.

Yes, indeed Unix v5 (fifth edition from 1974, that is _not_ SysV!),
does allow root to make hard links on directories.  But the seventh
edition from 1978 already prohibits it.  (sorry, at the moment I don't
have a v6 at hand to test it there...  ;-))

Every more modern Unix I tried, whether free or proprietary, whether
SysV or BSD based, refuses to do this even for root.

So I'd think that this case can be safely ignored.  I don't know about
non unixoid systems, though.

cheers
sascha
-- 
Parents strongly cautioned  --  this  posting  is  intended for mature
audiences  over  18.  It  may  contain some material that many parents
would not find suitable for children and may include intense violence,
sexual situations, coarse language and suggestive dialogue.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Can't interrupt directory_files_internal run from timer-event-handler
  2005-08-14 20:13           ` Sascha Wilde
@ 2005-08-15 16:04             ` Richard M. Stallman
  0 siblings, 0 replies; 12+ messages in thread
From: Richard M. Stallman @ 2005-08-15 16:04 UTC (permalink / raw)
  Cc: kzeitler, eliz, emacs-devel

    Yes, indeed Unix v5 (fifth edition from 1974, that is _not_ SysV!),
    does allow root to make hard links on directories.  But the seventh
    edition from 1978 already prohibits it.  (sorry, at the moment I don't
    have a v6 at hand to test it there...  ;-))

Thanks for looking this up.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-08-15 16:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-05  9:03 Can't interrupt directory_files_internal run from timer-event-handler Klaus Zeitler
2005-08-05 20:38 ` Richard M. Stallman
2005-08-06  6:57   ` Eli Zaretskii
2005-08-07 17:15     ` Richard M. Stallman
2005-08-07 18:15       ` Eli Zaretskii
2005-08-08  8:44         ` Johan Vromans
2005-08-08 14:32           ` Johan Vromans
2005-08-09  0:27         ` Richard M. Stallman
2005-08-14 20:13           ` Sascha Wilde
2005-08-15 16:04             ` Richard M. Stallman
2005-08-09 23:15     ` Stefan Monnier
2005-08-09 23:07   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).