rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* RE: intr and RC
@ 1997-01-08 20:01 Mark K. Gardner
  1997-01-09 11:09 ` Tim Goodwin
  0 siblings, 1 reply; 16+ messages in thread
From: Mark K. Gardner @ 1997-01-08 20:01 UTC (permalink / raw)
  To: rc

I have the intr working with rc now. The solution (with credits):

 * convert setjmp/longjmp to sigsetjmp/siglongjmp (Soren Dayton)

 * #define SVSIGS in config.h (I forgot who suggested it)

 * compiled with -DSYSVR4 (Scott Schwartz)

 * could not link with -lbsd, no such library on Solaris (Paul Haahr)

 * sigchk patch for input.c (Alan Watson)

along with the following:

 * convert readline setjmp/longjmp (hint: Alan Watson's readline-less post)

Thanks all who responded. I have a patch file for the above changes.
Where should I submit it?

-- 
Mark K. Gardner (mkgardne@cs.uiuc.edu)
University of Illinois at Urbana-Champaign
Real-Time Systems Laboratory
-- 


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: intr and RC
@ 1997-01-13  1:33 Scott Schwartz
  0 siblings, 0 replies; 16+ messages in thread
From: Scott Schwartz @ 1997-01-13  1:33 UTC (permalink / raw)
  To: luyer; +Cc: rc

scp with rc1.5 works for me.



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: intr and RC
@ 1997-01-12 23:39 Scott Schwartz
  1997-01-13  0:52 ` David Luyer
  0 siblings, 1 reply; 16+ messages in thread
From: Scott Schwartz @ 1997-01-12 23:39 UTC (permalink / raw)
  To: byron, rc

	I am not sure what this bug is but the bug that last bit me with
	Solaris and which I consider a showstopper is this:

		rsh solaris-machine ls

	The last time I ran this command rc would hang after running ls,
	because rc on the solaris machine was getting no child pids back
	from wait().

I can't reproduce that, with a recent version of solaris.

% uname -a
SunOS vorlon.cse.psu.edu 5.5.1 Generic_103640-03 sun4m sparc SUNW,SPARCstation-4

% cc -V
cc: SC4.0 18 Oct 1995 C 4.0

Here are all the changes I've made to the distributed code:

% rcsdiff -c RCS/*

*** /tmp/T0a00295	Sun Jan 12 18:29:27 1997
--- Makefile	Fri May 31 02:08:02 1996
***************
*** 16,28 ****
  #ADDON=addon.o
  
  # Use an ANSI compiler (or at least one that groks prototypes and void *):
! CC=gcc -g -O
! CFLAGS=
  LDFLAGS=
  
  # You may substitute "bison -y" for yacc. (You want to choose the one that
  # makes a smaller y.tab.c. Also see the README about Sun's yacc.)
! YACC=yacc
  
  OBJS=$(ADDON) builtins.o except.o exec.o $(EXECVE) fn.o footobar.o getopt.o \
  	glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o \
--- 16,30 ----
  #ADDON=addon.o
  
  # Use an ANSI compiler (or at least one that groks prototypes and void *):
! CC=cc
! # -cg92
! #CC=insight 
! CFLAGS=  -O -fast -DSYSVR4
  LDFLAGS=
  
  # You may substitute "bison -y" for yacc. (You want to choose the one that
  # makes a smaller y.tab.c. Also see the README about Sun's yacc.)
! YACC=bison -y
  
  OBJS=$(ADDON) builtins.o except.o exec.o $(EXECVE) fn.o footobar.o getopt.o \
  	glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o \
No differences encountered
*** /tmp/T0a00295	Sun Jan 12 18:29:27 1997
--- footobar.c	Fri May 31 01:45:46 1996
***************
*** 9,15 ****
  
  #ifdef PROTECT_ENV
  static bool Fconv(Format *f, int ignore) {
! 	unsigned const char *s = va_arg(f->args, unsigned const char *);
  	int c;
  
  	while ((c = *s++) != '\0')
--- 9,15 ----
  
  #ifdef PROTECT_ENV
  static bool Fconv(Format *f, int ignore) {
! 	const unsigned char *s = va_arg(f->args, const unsigned char *);
  	int c;
  
  	while ((c = *s++) != '\0')
*** /tmp/T0a00295	Sun Jan 12 18:29:27 1997
--- input.c	Fri May 31 01:45:47 1996
***************
*** 140,145 ****
--- 140,147 ----
  				long /*ssize_t*/ r = rc_read(istack->fd, inbuf + 2, BUFSIZE);
  				sigchk();
  				if (r < 0) {
+ 					if (errno == EINTR) /*retry interrupted read*/
+ 						continue;
  					uerror("read");
  					rc_exit(1);
  				}
*** /tmp/T0a00295	Sun Jan 12 18:29:28 1997
--- print.c	Fri May 31 01:45:44 1996
***************
*** 219,225 ****
   */
  
  extern void fmtappend(Format *format, const char *s, SIZE_T len) {
! 	while (format->buf + len > format->bufend) {
  		SIZE_T split = format->bufend - format->buf;
  		memcpy(format->buf, s, split);
  		format->buf += split;
--- 219,225 ----
   */
  
  extern void fmtappend(Format *format, const char *s, SIZE_T len) {
! 	while (len > format->bufend - format->buf) {
  		SIZE_T split = format->bufend - format->buf;
  		memcpy(format->buf, s, split);
  		format->buf += split;
***************
*** 240,246 ****
   */
  
  extern int printfmt(Format *format, const char *fmt) {
! 	unsigned const char *s = (unsigned const char *) fmt;
  
  	if (fmttab[0] == NULL)
  		inittab();
--- 240,246 ----
   */
  
  extern int printfmt(Format *format, const char *fmt) {
! 	const unsigned char *s = (const unsigned char *) fmt;
  
  	if (fmttab[0] == NULL)
  		inittab();
***************
*** 314,319 ****
--- 314,320 ----
  
  static void memprint_grow(Format *format, SIZE_T more) {
  	char *buf;
+ 	SIZE_T pos = format->buf - format->bufbegin;
  	SIZE_T len = format->bufend - format->bufbegin + 1;
  	len = (len >= more)
  		? len * 2
***************
*** 325,331 ****
  		buf = nalloc(len);
  		memcpy(buf, format->bufbegin, used);
  	}
! 	format->buf	 = buf + (format->buf - format->bufbegin);
  	format->bufbegin = buf;
  	format->bufend	 = buf + len - 1;
  }
--- 326,332 ----
  		buf = nalloc(len);
  		memcpy(buf, format->bufbegin, used);
  	}
! 	format->buf	 = buf + pos;
  	format->bufbegin = buf;
  	format->bufend	 = buf + len - 1;
  }
*** /tmp/T0a00295	Sun Jan 12 18:29:29 1997
--- signal.c	Fri May 31 01:45:50 1996
***************
*** 66,72 ****
  	void (*h)(int);
  	int i;
  	for (i = 1; i < NUMOFSIGNALS; i++) {
! 		if ((h = signal(i, SIG_DFL)) != SIG_DFL)
  			signal(i, h);
  		sighandlers[i] = h;
  	}
--- 66,73 ----
  	void (*h)(int);
  	int i;
  	for (i = 1; i < NUMOFSIGNALS; i++) {
! 		h = signal(i, SIG_DFL);
! 		if (h != SIG_ERR && h != SIG_DFL)
  			signal(i, h);
  		sighandlers[i] = h;
  	}


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: intr and RC
@ 1997-01-12 23:17 Byron Rakitzis
  0 siblings, 0 replies; 16+ messages in thread
From: Byron Rakitzis @ 1997-01-12 23:17 UTC (permalink / raw)
  To: rc, schwartz, tim

I am not sure what this bug is but the bug that last bit me with
Solaris and which I consider a showstopper is this:

	rsh solaris-machine ls

The last time I ran this command rc would hang after running ls,
because rc on the solaris machine was getting no child pids back
from wait().

I don't know if it's worth doing a 1.5.2 for Solaris unless this
bug is fixed. It doesn't have anything to do with setjmp and longjmp
and signals as far as I know.

I got around this bug running a 4.1.x binary, or linking with a
bsd library. It may not be called -lbsd, but there is some kind
of compatability library for BSD available.



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: intr and RC
@ 1997-01-09 21:59 Scott Schwartz
  0 siblings, 0 replies; 16+ messages in thread
From: Scott Schwartz @ 1997-01-09 21:59 UTC (permalink / raw)
  To: rc, tim

What exactly is the bug?  Until someone can explain what is
going on, I'd rather not see the patch be official.  (Maybe
I just haven't exercised Solaris hard enough, but I haven't
run across problems.)



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: intr and RC
@ 1997-01-08  7:45 Bengt Kleberg
  0 siblings, 0 replies; 16+ messages in thread
From: Bengt Kleberg @ 1997-01-08  7:45 UTC (permalink / raw)
  To: rc

> From: Scott Schwartz <schwartz@galapagos.cse.psu.edu>
> 
> "Mark K. Gardner" <mkgardne@cs.uiuc.edu> writes:
> | Has anyone else managed to
> | compile rc and get interrupts to work properly? I *love* rc, but this
> | is driving me crazy!
> 
> I compiled it (CFLAGS=-DSYSVR4), and it works fine with no changes,
> so far as I can tell.
> 
Ditto.

Best Wishes, Bengt
--------------------------------------------------------------------
Email: Bengt.Kleberg@enea.se (Enea Data AB, Sweden)
Disclaimer: Nothing abovementioned has any connection to Enea Data AB
``At the moment money does indeed make the world go round but unfortunately
  the direction of that applied rotation is all downhill.'' fleecy@netreach.net


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: intr and RC
@ 1997-01-07 19:55 Alan Watson
  0 siblings, 0 replies; 16+ messages in thread
From: Alan Watson @ 1997-01-07 19:55 UTC (permalink / raw)
  To: rc

I've looked at this for a little while and these diffs seems to work
for me on

    SunOS charon 5.5 Generic sun4u sparc SUNW,Ultra-1
    
when compiled with c89 and without -lbsd or -lreadline.

There seem to be two things to get right: the behaviour on interrupts
with and without a handler. I think this does the right thing, but rc
signals are pretty much Greek to me.

Regards,

Alan

*** config.h.orig   Tue Jan  7 12:39:57 1997
--- config.h    Tue Jan  7 12:39:46 1997
***************
*** 130,140 ****
  #define DEFAULTPATH "/usr/bsd", "/usr/sbin", "/usr/bin", "/bin", "."
  #endif
  
! #ifdef sun        /* Used on SunOS 4.1.1 */
! #define PROTECT_ENV
! #undef DEFAULTPATH
! #define DEFAULTPATH "/usr/ucb", "/usr/bin", "."
  #endif
  
  /*
   * Suggested settings for HP300 running 4.3BSD-utah (DWS):
--- 130,151 ----
  #define DEFAULTPATH "/usr/bsd", "/usr/sbin", "/usr/bin", "/bin", "."
  #endif
  
! #ifdef sun
! #ifdef __SVR4     /* Used on Solaris */
!   #ifndef SYSVR4
!   #define SYSVR4
!   #endif
!   #define NOSIGCLD
!   #define SVSIGS
!   #define PROTECT_ENV
!   #undef DEFAULTPATH
!   #define DEFAULTPATH "/usr/ucb", "/usr/bin", "."
! #else     /* Used on SunOS 4.1.1 */
!   #define PROTECT_ENV
!   #undef DEFAULTPATH
!   #define DEFAULTPATH "/usr/ucb", "/usr/bin", "."
  #endif
+ #endif
  
  /*
   * Suggested settings for HP300 running 4.3BSD-utah (DWS):
*** input.c.orig    Tue Jan  7 11:03:30 1997
--- input.c Tue Jan  7 12:52:00 1997
***************
*** 137,144 ****
            } else
  #endif
                {
!               long /*ssize_t*/ r = rc_read(istack->fd, inbuf + 2, BUFSIZE);
!               sigchk();
                if (r < 0) {
                    uerror("read");
                    rc_exit(1);
--- 137,148 ----
            } else
  #endif
                {
!               long /*ssize_t*/ r;
!               do {
!                   errno = 0;
!                   r = rc_read(istack->fd, inbuf + 2, BUFSIZE);
!                   sigchk();
!               } while (r < 0 && errno == EINTR);
                if (r < 0) {
                    uerror("read");
                    rc_exit(1);


^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: intr and RC
@ 1997-01-07 18:00 Alan Watson
  0 siblings, 0 replies; 16+ messages in thread
From: Alan Watson @ 1997-01-07 18:00 UTC (permalink / raw)
  To: rc

> (As an aside, a SunOS 4.x binary of rc will probably work correctly on
> rc where a Solaris 2.5 binary compiled w/o -lbsd will do the wrong thing.)

My experience is that a SunOS 4.x binary traps the first interrupt
successfully, but then exits on the second.

Regards,

Alan


^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: intr and RC
@ 1997-01-07 17:03 Mark K. Gardner
  1997-01-07 17:16 ` Scott Schwartz
  1997-01-07 17:46 ` Paul Haahr
  0 siblings, 2 replies; 16+ messages in thread
From: Mark K. Gardner @ 1997-01-07 17:03 UTC (permalink / raw)
  To: rc

  mark> I have been having trouble interrupting commands in RC.
  mark> Sometimes when I ctl-c (which I have intr set to) the command
  mark> fails to stop. Other times it stops just fine. (Naturally, it
  mark> fails to stop when I have invoked a long running program,
  mark> rather than when it is a short running command.) I did not
  mark> find any mention of the problem on the rc-list. Has anyone
  mark> else seen this? Any suggestion on how to find the problem?
  mark> Configuration:
  mark> rc-1.5 (linux version from sunsite which differs from the
  mark> official 1.5beta in its add-ons), Solaris v2.5.1, readline,
  mark> static linkage, gcc v2.7.1 with -O2 and with a hack for
  mark> ~/<path expansion> (which I cannot see how it would prevent
  mark> intr from being acknowledged).

  Soren> I have not looked at the rc code in a while, but this problem
  Soren> appeared in es and it turned out that we should be using
  Soren> sigsetjmp() and siglongjmp() rather than longjmp() and
  Soren> setjmp().

I implemented the suggestion that Soren Dayton made (the difference
between SysV4 and BSD setjmp/longjmp is documented in the Solaris
Porting FAQ on sunsite), but the problem still exists. I can't believe
that I am the only one using rc on Solaris. Has anyone else managed to
compile rc and get interrupts to work properly? I *love* rc, but this
is driving me crazy!

-- 
Mark K. Gardner (mkgardne@cs.uiuc.edu)
University of Illinois at Urbana-Champaign
Real-Time Systems Laboratory
-- 


^ permalink raw reply	[flat|nested] 16+ messages in thread
* intr and RC
@ 1996-12-31 21:53 Mark K. Gardner
  1996-12-31 22:01 ` Soren Dayton
  0 siblings, 1 reply; 16+ messages in thread
From: Mark K. Gardner @ 1996-12-31 21:53 UTC (permalink / raw)
  To: rc

I have been having trouble interrupting commands in RC. Sometimes when
I ctl-c (which I have intr set to) the command fails to stop. Other
times it stops just fine. (Naturally, it fails to stop when I have
invoked a long running program, rather than when it is a short running
command.) I did not find any mention of the problem on the rc-list.
Has anyone else seen this? Any suggestion on how to find the problem?

Configuration:

rc-1.5 (linux version from sunsite which differs from the official
1.5beta in its add-ons), Solaris v2.5.1, readline, static linkage, gcc
v2.7.1 with -O2 and with a hack for ~/<path expansion> (which I cannot
see how it would prevent intr from being acknowledged).

-- 
Mark K. Gardner (mkgardne@cs.uiuc.edu)
University of Illinois at Urbana-Champaign
Real-Time Systems Laboratory
-- 


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

end of thread, other threads:[~1997-02-11 21:32 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-08 20:01 intr and RC Mark K. Gardner
1997-01-09 11:09 ` Tim Goodwin
  -- strict thread matches above, loose matches on Subject: below --
1997-01-13  1:33 Scott Schwartz
1997-01-12 23:39 Scott Schwartz
1997-01-13  0:52 ` David Luyer
1997-02-11 13:57   ` Markus Friedl
1997-01-12 23:17 Byron Rakitzis
1997-01-09 21:59 Scott Schwartz
1997-01-08  7:45 Bengt Kleberg
1997-01-07 19:55 Alan Watson
1997-01-07 18:00 Alan Watson
1997-01-07 17:03 Mark K. Gardner
1997-01-07 17:16 ` Scott Schwartz
1997-01-07 17:46 ` Paul Haahr
1996-12-31 21:53 Mark K. Gardner
1996-12-31 22:01 ` Soren Dayton

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 NNTP newsgroup(s).