unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: insert-file-contents and fifos
       [not found] <871ycwrm2e.fsf@etla.org>
@ 2002-05-05  5:34 ` Richard Stallman
  2002-05-05 12:14   ` Vivek
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2002-05-05  5:34 UTC (permalink / raw)
  Cc: emacs-devel

I don't really know how to use fifos, so I can't make a test case.
Can you send a specific test case with which to observe this problem?

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

* Re: insert-file-contents and fifos
  2002-05-05  5:34 ` insert-file-contents and fifos Richard Stallman
@ 2002-05-05 12:14   ` Vivek
  2002-05-06  6:24     ` Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Vivek @ 2002-05-05 12:14 UTC (permalink / raw)
  Cc: emacs-devel@gnu.org

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1406 bytes --]

On Sat, 4 May 2002, Richard Stallman wrote:

> I don't really know how to use fifos, so I can't make a test case.
> Can you send a specific test case with which to observe this problem?

The attached perl script, when run, will create a fifo called .sig-dyn,
daemonise, and sit attached to it, emitting a signature each time
.sig-dyn is read from. If ~/sigd/sigfile (I do means "sigd", it's not a
typo) is not present, then it uses fortune(6) as a source.

GNU emacs 20 was capable of reading from this, 21 is not. The change
appears to be the introduction of the new read_non_regular function
in fileio.c : a strace shows emacs fetching the data from the file
( you can see the data being read ), and then aborting. Presumably
the state of a fifo is sufficiently different from a non-regular file
that read_non_regular reacts as if an error has occurred.

There is a (possibly architecturally bad) patch on savannah.gnu.org
that restores the old GNU emacs 20 behaviour specifically for fifos,
while leaving all other file types to the new code. The patch is
against the version of GNU emacs 21.1 (21.1-7) shipped with Debian
GNU/Linux (woody) a while ago now - woody ships with 21.2-1 now.

If there are any problems with getting the sigerator working, let me know.
( It should be pretty straightforward, I usually run it from my home
  directory, but it should be Ok anywhere it has write permission ).


[-- Attachment #2: Type: TEXT/PLAIN, Size: 1254 bytes --]

#!/usr/bin/perl

use Fcntl;
use strict;
use vars qw(@sig $sig $lidx);

my $FIFO = '.sig-dyn';
#$SIG{PIPE} = sub { warn("Broken pipe: $!\n") };
$SIG{PIPE} = 'IGNORE';
$SIG{HUP} = \&readsigs;
$SIG{TERM} = sub { exit(0) };

sub readsigs ()
{
    chdir;
    if(sysopen(SIGS, join('/',$ENV{HOME}, qw(sigd sigfile)), O_RDONLY, undef))
    {
	$/ = "--\n";
	chomp(@sig = <SIGS>);
	close(SIGS);
	$sig =
	  sub
	  {
	      my $idx;
	      for($idx = $lidx; $idx == $lidx; $idx = int(rand(@sig))) {}
	      join('', "-- \n", $sig[$lidx = $idx]);
	  };
    }
    else { $sig = sub { "-- \n".`fortune -s` } }

    unless(-p $FIFO)
    {
	rename($FIFO, "$FIFO~");	
	system(mkfifo => $FIFO)
	  && system(mknod => $FIFO, 'p')
	    && die("mk{nod|fifo} failed: $!\n");
    }
}

readsigs();

fork() && exit(0);

SIGLOOP:
{
    my $wi = '';
    my $wo = '';

    while (-p $FIFO)
    {
	my $s = $sig->();
	my $l = length($s);
	sysopen(FIFO, $FIFO, O_WRONLY|O_SYNC, undef)
          || die("sysopen(FH, $FIFO, O_WRONLY|O_SYNC, undef) failed: $!\n");
        syswrite(FIFO, $s, $l, 0);
        close(FIFO);
        select(undef(), undef(), undef(), 0.5);
    }
}

warn("$FIFO is not a pipe: exiting\n");
exit(0);

[-- Attachment #3: Type: TEXT/PLAIN, Size: 6378 bytes --]

fsck -f -b 8193 /dev/cortex
--
Come, Goratrix, we must return to the chantry to prepare for tomorrow night!
What are we gonna do tomorrow night, Tremere?
The same thing we do every night, Goratrix: Try to Take Over The World!
--
No good deed goes unpunished.
--
Death before decaf.
--
If voting could change things, it would be illegal.
--
Just one nuclear family can ruin your whole life.
--
Sysadmin (n): The untrained being underpaid for doing the impossible with
the obsolete
--
I dunno about the Big Bang. The Big Kludge I can believe in.
--
You are in a maze of twisty X resources, all like.
--
If we all work together, we can totally disrupt the system.
--
I'm just a simple-minded vice-president in charge of operations...
--
"He was too young to be taken from us."
             'You were the one who cut him in half with a chainsaw, dude.'
--
Nobody wants constructive criticism.  It's all we can do to put up with
constructive praise.
--
"whip me, beat me, make me administer aix!" -andrew
--
"I don't suffer from insanity, I enjoy every moment of it" - Anon
--
It is easier to get forgiveness than permission.
--
He's been shot through the chest with an arrow.
What about his horse?
I don't think anyone's shot him with that.
--
"Always try to do things in chronological order; it's less confusing
that way."
--
"They're unfriendly, which is fortunate, really.  They'd be difficult
to like."
                -- Avon
--
"Outside of a dog, a book is a man's best friend: and inside a dog,
it's too dark to read."
                -- Groucho Marx
--
Reader, suppose you were an idiot.  And suppose you were a member of
Congress.  But I repeat myself.
                -- Mark Twain
--
My mother loved children - she would have given anything if I had been one.
                -- Groucho Marx
--
I've had a perfectly wonderful evening.  But this wasn't it.
                -- Groucho Marx
--
"Am I missing something else? The same configuration is working fine elsewhere
(albeit with a different OS, computer and network)..."
                                             -- seen on a mailing list
--
When someone says "I want a programming language in which I need only
say what I wish done," give him a lollipop.
--
"I like work ... I can sit and watch it for hours."
--
By doing just a little every day, you can gradually let the task
completely overwhelm you.
--
Everyone would _like_ a first. By the time you get to the third year,
you become more fatalistic, until you get to the point when a kippered
herring with a Warwick crest on it would be as welcome as a degree.
                                                    - Stephen Williams
--
"I don't want to go to the movies to be horrified and depressed."
"No, I suppose you've got real life to do that."
--
It is by caffeine alone I set my mind in motion,
It is by the beans of Java that thoughts acquire speed,
The hands acquire a shaking, the shaking becomes a warning,
It is by caffeine alone I set my mind in motion
--
You go insane if you go without sleep for too long.
And not in a good way, either.
--
Sleep, where is thy sting, 
Bed, where is thy victory...
                   -- Insomnia? Me?
--
Manual? We've just been pushing buttons til it works...
--
There's an old proverb that says just about whatever you want it to.
--
Putt knot yore trussed inn spell chequers
--
What's the plural of mongoose? Mongooses? Mongeese? Polygoose?
--
I am worthless. I struggle with the simple things. It seems so easy for 
everyone else. One armed blind people climb mountains and teenagers get
Ph.D's. I have trouble getting out of bed.
                                          -TMCM
--
That which doesn't kill you will make you bitter and cynical.
                                                            -TMEG
--
"Aren't you ashamed of yourself?"
"No, I have people to do that for me."
--
Stupid, _stupid_ rat creatures...
--
Lusers. Can't live with 'em, can't run 'em over in the car park and make
it look like an accident...
--
The time you enjoy wasting is not wasted time. 
                                           -- Bertrand Russell
--
"It is two days later and I am still at the office. I did not go and chase
coots. There is too much work to do. I want to die." 
                                                    -- Jamie Zawinski
--
Q: Why did the tachyon cross the road? 
A: Because it was on the other side. 
--
To err is human, To purr feline. -- Robert Byrne
--
To err is human, To moo bovine.
--
I think my memory is implemented as a dissociative array...
--
"A distributed system is one in which I cannot get something done
because a machine I've never heard of is down"   
                                                --Leslie Lamport
--
"As you point out, EFAULT situations are `undefined' which means the
machine is entitled to grow wings an launch itself towards the sun..."
 -- Chris Wedgwood on the linux-kernel mailing list
--
"... I've seen Sun monitors on fire off the side of the multimedia lab.
I've seen NTU lights glitter in the dark near the Mail Gate.  All these
things will be lost in time, like the root partition last week.  Time
to die..." - Peter Gutmann - a.s.r
--
I'm an apatheist. The question is no longer interesting, 
and the answer no longer matters. - petro - a.s.r
--
In German "invent-a-new-word-where-a-perfectly-good-one-already-exists" 
is probably a word. - Peter da Silva - a.s.r
--
I must be sad when I have cause, and smile at no  man's jests; 
eat when I have stomach, and wait for no man's leisure; 
sleep when I am drowsy, and tend on no man's business; 
laugh when I am merry, and claw no man in his humour.
--
What they don't know can't hurt them.
That's not really true of Air Traffic Control, now, is it?
--
        "Do you think there's a God?"
        "Well, SOMEbody's out to get me!"
                -- Calvin and Hobbs
--
Either I'm dead or my watch has stopped.
                -- Groucho Marx's last words
--
The time for action is past!  Now is the time for senseless bickering.
--
I understand your language perfectly.
Je parle français comme une vache espagnole.
Hablo español como un gringo borracho.
Ich sprechen deutsch wie italienisch Fussballtrainer.


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

* Re: insert-file-contents and fifos
  2002-05-05 12:14   ` Vivek
@ 2002-05-06  6:24     ` Richard Stallman
  2002-05-06 15:26       ` Vivek
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2002-05-06  6:24 UTC (permalink / raw)
  Cc: emacs-devel

    GNU emacs 20 was capable of reading from this, 21 is not. The change
    appears to be the introduction of the new read_non_regular function
    in fileio.c : a strace shows emacs fetching the data from the file
    ( you can see the data being read ), and then aborting. Presumably
    the state of a fifo is sufficiently different from a non-regular file
    that read_non_regular reacts as if an error has occurred.

Could you step through it and see why this happens?
The code looks straightforward, so I don't see why it would fail.

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

* Re: insert-file-contents and fifos
  2002-05-06  6:24     ` Richard Stallman
@ 2002-05-06 15:26       ` Vivek
  2002-05-07  4:58         ` Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Vivek @ 2002-05-06 15:26 UTC (permalink / raw)
  Cc: emacs-devel@gnu.org

On Mon, 6 May 2002, Richard Stallman wrote:

>     GNU emacs 20 was capable of reading from this, 21 is not. The change
>     appears to be the introduction of the new read_non_regular function
>     in fileio.c : a strace shows emacs fetching the data from the file
>     ( you can see the data being read ), and then aborting. Presumably
>     the state of a fifo is sufficiently different from a non-regular file
>     that read_non_regular reacts as if an error has occurred.
>
> Could you step through it and see why this happens?
> The code looks straightforward, so I don't see why it would fail.

Maybe I'm being dense, or just don't understand what the code is meant to
do, but:

`read_non_regular' _always_ calls

  Fsignal (Qquit, Qnil);

just after `emacs_read' (which succeeds, afaict)

and the call to `read_non_regular' in `insert-file-contents' is wrapped
in an `internal_condition_case_1' call: so is it _ever_ possible for
a read of a non regular file to succeed, since:

val = internal_condition_case_1 ( read_non_regular, Qnil, Qerror,
				  read_non_regular_quit );

if (NILP (val))
  {
    read_quit = 1;
    break;
  }

So, according to my (albeit limited) understanding, we're calling
internal_condition_case_1, which calls read_non_regular, which
will _always_ signal '(quit . nil), which will therefore always
result in a 'nil return from internal_condition_case_1 : can
insert-file-contents read any non regular files at all? I tried
with both ~/.sig-dyn and /dev/fd0 and both resulted in the same
behaviour: a successful read(2) of the available data (or the first
65536 bytes in thcase of /dev/fd0) followed by a bailout.

I'm confused... for the record, here's the read_non_regular that I have:

static Lisp_Object
read_non_regular ()
{
  int nbytes;

  immediate_quit = 1;
  QUIT;

  nbytes = emacs_read (non_regular_fd,
		       BEG_ADDR + PT_BYTE - 1 + non_regular_inserted,
		       non_regular_nbytes);

  Fsignal (Qquit, Qnil);
  immediate_quit = 0;

  return make_number (nbytes);
}

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

* Re: insert-file-contents and fifos
  2002-05-06 15:26       ` Vivek
@ 2002-05-07  4:58         ` Richard Stallman
  2002-05-07 16:51           ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2002-05-07  4:58 UTC (permalink / raw)
  Cc: emacs-devel

    `read_non_regular' _always_ calls

      Fsignal (Qquit, Qnil);

    just after `emacs_read' (which succeeds, afaict)

How strange--the 21.2 code really has that absurd call to Fsignal.
The latest development version does not have it; I think it was
inserted by mistake.

Eli, could you delete that Fsignal call?


read_non_regular ()
{
  int nbytes;
  
  immediate_quit = 1;
  QUIT;
  nbytes = emacs_read (non_regular_fd,
		       BEG_ADDR + PT_BYTE - 1 + non_regular_inserted,
		       non_regular_nbytes);
  Fsignal (Qquit, Qnil);
  immediate_quit = 0;
  return make_number (nbytes);
}

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

* Re: insert-file-contents and fifos
  2002-05-07  4:58         ` Richard Stallman
@ 2002-05-07 16:51           ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2002-05-07 16:51 UTC (permalink / raw)
  Cc: vivek, emacs-devel

> From: Richard Stallman <rms@gnu.org>
> Date: Mon, 6 May 2002 22:58:41 -0600 (MDT)
> 
> Eli, could you delete that Fsignal call?

Done.

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

end of thread, other threads:[~2002-05-07 16:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <871ycwrm2e.fsf@etla.org>
2002-05-05  5:34 ` insert-file-contents and fifos Richard Stallman
2002-05-05 12:14   ` Vivek
2002-05-06  6:24     ` Richard Stallman
2002-05-06 15:26       ` Vivek
2002-05-07  4:58         ` Richard Stallman
2002-05-07 16:51           ` Eli Zaretskii

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).