Compare commits

...

2 Commits
master ... f20

Author SHA1 Message Date
Pavel Raiskup 3b0d2dc8ba spec: remove unused patches from git
Version: 6.18.01-6
2015-01-27 07:33:31 +01:00
Pavel Raiskup bc7aea1b23 tcsh: fix hang in 'wait' built-in
Resolves: rhbz#1181685
Version: 6.18.01-6
2015-01-27 07:32:07 +01:00
5 changed files with 101 additions and 314 deletions

View File

@ -1,77 +0,0 @@
--- tcsh-6.14.00/sh.h.wide-seeks 2005-03-25 19:46:41.000000000 +0100
+++ tcsh-6.14.00/sh.h 2006-09-26 18:26:33.000000000 +0200
@@ -801,6 +801,13 @@
* exactly one if the input is seekable and tell is available.
* In other cases, the shell buffers enough blocks to keep all loops
* in the buffer.
+ *
+ * If (WIDE_STRINGS && cantell), fbobp is always a byte offset, but
+ * (fseekp - fbobp) and (feobp - fbobp) are character offsets (usable for
+ * fbuf indexing).
+ *
+ * If (!cantell), all offsets are character offsets; if (!WIDE_STRINGS), there
+ * is no difference between byte and character offsets.
*/
EXTERN struct Bin {
off_t Bfseekp; /* Seek pointer, generally != lseek() value */
@@ -824,7 +831,7 @@
#define TCSH_F_SEEK 2 /* File seek */
#define TCSH_E_SEEK 3 /* Eval seek */
union {
- off_t _f_seek;
+ off_t _f_seek; /* A byte offset if (cantell) */
Char* _c_seek;
} fc;
#define f_seek fc._f_seek
--- tcsh-6.14.00/sh.lex.c.wide-seeks 2006-09-26 18:26:33.000000000 +0200
+++ tcsh-6.14.00/sh.lex.c 2006-09-26 18:28:10.000000000 +0200
@@ -1694,7 +1694,8 @@
char cbuf[BUFSIZE + 1];
ssize_t res, r;
size_t partial;
-
+ int err;
+
assert (nchars <= sizeof(cbuf)/sizeof(*cbuf));
USE(use_fclens);
res = 0;
@@ -1736,7 +1737,11 @@
memmove(cbuf, cbuf + i, partial - i);
partial -= i;
} while (partial != 0 && nchars != 0);
- /* Throwing away possible partial multibyte characters on error */
+ /* Throwing away possible partial multibyte characters on error if the
+ stream is not seekable */
+ err = errno;
+ lseek(fildes, -(off_t)partial, L_INCR);
+ errno = err;
return res != 0 ? res : r;
}
@@ -1753,7 +1758,13 @@
(void) lseek(SHIN, fseekp, L_SET);
}
if (fseekp == feobp) {
- fbobp = feobp;
+ off_t bytes;
+ size_t i;
+
+ bytes = fbobp;
+ for (i = 0; i < (size_t)(feobp - fbobp); i++)
+ bytes += fclens[i];
+ fbobp = fseekp = feobp = bytes;
do
c = wide_read(SHIN, fbuf[0], BUFSIZE, 1);
while (c < 0 && errno == EINTR);
@@ -1926,9 +1937,9 @@
return;
case TCSH_F_SEEK:
#ifdef WIDE_STRINGS
- if (cantell && fseekp >= fbobp && fseekp < feobp) {
+ if (cantell && fseekp >= fbobp && fseekp <= feobp) {
size_t i;
-
+
l->f_seek = fbobp;
for (i = 0; i < fseekp - fbobp; i++)
l->f_seek += fclens[i];

View File

@ -1,181 +0,0 @@
diff -up tcsh-6.17.00/sh.glob.c.glob-automount tcsh-6.17.00/sh.glob.c
--- tcsh-6.17.00/sh.glob.c.glob-automount 2008-06-19 17:20:56.000000000 +0200
+++ tcsh-6.17.00/sh.glob.c 2009-11-04 13:58:09.000000000 +0100
@@ -423,6 +423,14 @@ handleone(Char *str, Char **vl, int acti
return (str);
}
+static char **blkend(char **up)
+{
+
+ while (*up)
+ up++;
+ return (up);
+}
+
static Char **
libglob(Char **vl)
{
@@ -430,6 +438,13 @@ libglob(Char **vl)
glob_t globv;
char *ptr;
int nonomatch = adrof(STRnonomatch) != 0, magic = 0, match = 0;
+ char **snowc = NULL;
+ char **nowc;
+ char **globres;
+ char **sres;
+ char **res;
+ int size = GLOBSPACE;
+ int cglob = 0, fglob = 0;
if (!vl || !vl[0])
return(vl);
@@ -438,35 +453,126 @@ libglob(Char **vl)
globv.gl_pathv = 0;
globv.gl_pathc = 0;
+ sres = res = (Char **) xmalloc((size_t) (size * sizeof(Char *)));
+ *res = NULL;
+
if (nonomatch)
gflgs |= GLOB_NOCHECK;
do {
- ptr = short2qstr(*vl);
- switch (glob(ptr, gflgs, 0, &globv)) {
- case GLOB_ABEND:
- globfree(&globv);
- setname(ptr);
- stderror(ERR_NAME | ERR_GLOB);
- /* NOTREACHED */
- case GLOB_NOSPACE:
- globfree(&globv);
- stderror(ERR_NOMEM);
- /* NOTREACHED */
- default:
- break;
- }
- if (globv.gl_flags & GLOB_MAGCHAR) {
- match |= (globv.gl_matchc != 0);
- magic = 1;
+ ptr = short2qstr(*vl);
+ if (!any(ptr, '?') && !any(ptr, '*') && !any(ptr, '[') && !any(ptr, ']'))
+ {
+ ptr = short2str(*vl);
+ if (snowc == NULL)
+ snowc = nowc = (Char **) xmalloc((size_t) ((blklen(vl) + 1) * sizeof(Char *)));
+ *nowc++ = SAVE(ptr);
+ *nowc = NULL;
+
+ continue;
+
+ }
+ else
+ cglob++;
+ switch (glob(ptr, gflgs, 0, &globv)) {
+ case GLOB_ABEND:
+ globfree(&globv);
+ setname(ptr);
+ stderror(ERR_NAME | ERR_GLOB);
+ /* NOTREACHED */
+ case GLOB_NOSPACE:
+ globfree(&globv);
+ stderror(ERR_NOMEM);
+ /* NOTREACHED */
+ default:
+ break;
+ }
+ if (globv.gl_flags & GLOB_MAGCHAR) {
+ match |= (globv.gl_matchc != 0);
+ magic = 1;
+ }
+
+ globres = (globv.gl_pathc == 0 || (magic && !match && !nonomatch)) ?
+ NULL : blk2short(globv.gl_pathv);
+
+ if (snowc != NULL)
+ {
+ while ((blklen(sres) + blklen(snowc)) >= size) {
+ size += GLOBSPACE;
+ sres = (Char **) xrealloc((ptr_t) sres, (size_t) (size * sizeof(Char *)));
+ }
+
+ if (blklen(sres) == 0)
+ {
+ sres = blkcpy(sres, snowc);
+ res = blkend(sres);
+ }
+ else
+ {
+ res = blkend(sres);
+ res = blkcpy(res, snowc);
+ }
+ xfree(snowc);
+ snowc = NULL;
+ }
+
+ if (globres != NULL)
+ {
+ while ((blklen(sres) + blklen(globres)) >= size) {
+ size += GLOBSPACE;
+ sres = (Char **) xrealloc((ptr_t) sres, (size_t) (size * sizeof(Char *)));
+ }
+
+ if (blklen(sres) == 0)
+ {
+ sres = blkcpy(sres, globres);
+ res = blkend(sres);
+ }
+ else
+ {
+ res = blkend(sres);
+ res = blkcpy(res, globres);
+ }
+ xfree(globres);
+ globres = NULL;
}
- gflgs |= GLOB_APPEND;
+ else
+ fglob++;
+
+ globfree(&globv);
}
while (*++vl);
- vl = (globv.gl_pathc == 0 || (magic && !match && !nonomatch)) ?
- NULL : blk2short(globv.gl_pathv);
- globfree(&globv);
- return (vl);
+
+ if (snowc != NULL)
+ {
+ while ((blklen(sres) + blklen(snowc)) >= size) {
+ size += GLOBSPACE;
+ sres = (Char **) xrealloc((ptr_t) sres, (size_t) (size * sizeof(Char *)));
+ }
+
+ if (blklen(sres) == 0)
+ {
+ sres = blkcpy(sres, snowc);
+ res = blkend(sres);
+ }
+ else
+ {
+ res = blkend(sres);
+ res = blkcpy(res, snowc);
+ }
+ xfree(snowc);
+ snowc = NULL;
+ }
+
+ if ((cglob != 0) && (cglob == fglob))
+ return NULL;
+
+ if (blklen(sres) != 0)
+ vl = saveblk(sres);
+ else
+ vl = NULL;
+
+ return vl;
}
Char *

View File

@ -1,55 +0,0 @@
diff -upr tcsh-6.18.00_orig/ed.chared.c tcsh-6.18.00_work/ed.chared.c
--- tcsh-6.18.00_orig/ed.chared.c 2013-03-28 10:26:00.801939093 +0100
+++ tcsh-6.18.00_work/ed.chared.c 2013-03-28 10:30:37.000000000 +0100
@@ -957,6 +957,7 @@ GetHistLine()
{
struct Hist *hp;
int h;
+ int history;
if (Hist_num == 0) { /* if really the current line */
if (HistBuf.s != NULL)
@@ -979,8 +980,10 @@ GetHistLine()
if (hp == NULL)
return(CC_ERROR);
+ /* access only $history commands */
+ history = getn(varval(STRhistory));
for (h = 1; h < Hist_num; h++) {
- if ((hp->Hnext) == NULL) {
+ if ((hp->Hnext) == NULL || h >= history) {
Hist_num = h;
return(CC_ERROR);
}
diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
--- tcsh-6.18.00_orig/sh.hist.c 2013-03-28 10:26:00.794939068 +0100
+++ tcsh-6.18.00_work/sh.hist.c 2013-03-28 10:25:19.000000000 +0100
@@ -138,6 +138,7 @@ savehist(
int flg)
{
int histlen = 0;
+ int savehist = 0;
Char *cp;
/* throw away null lines */
@@ -151,6 +152,20 @@ savehist(
}
histlen = histlen * 10 + *cp++ - '0';
}
+
+ /* check savehist and history and use greater value to store all commands */
+ cp = varval(STRsavehist);
+ while (*cp) {
+ if (!Isdigit(*cp)) {
+ savehist = 0;
+ break;
+ }
+ savehist = savehist * 10 + *cp++ - '0';
+ }
+
+ if (savehist > histlen)
+ histlen = savehist;
+
if (sp)
(void) enthist(++eventno, sp, 1, flg, histlen);
discardExcess(histlen, flg);

View File

@ -0,0 +1,91 @@
From 788faac41b56f8b08e60f3456ad56c5a36fffa4c Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 27 Jan 2015 07:05:26 +0100
Subject: [PATCH 16/16] tcsh: fix 'wait' hang
Make sure that SIGCHLD is blocked before we call
handle_pending_signals() for the first time and before we actually
check for pp->p_flags & PRUNNING to make sure that the SIGCHLD is
not leaked meanwhile.
Resolves: rhbz#1181685
---
Fixes | 4 ++++
sh.proc.c | 26 +++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/Fixes b/Fixes
index 8eac9d4..56915a9 100644
--- a/Fixes
+++ b/Fixes
@@ -1,3 +1,7 @@
+ 29. Pavel Raiskup fix hang with:
+ while (1)
+ ( date & ; wait )
+ end
6. V6.18.01 - 20120214
5. fix interruptible wait again
4. ignore bogus compiler overflow message
diff --git a/sh.proc.c b/sh.proc.c
index e32ebda..0c5fc25 100644
--- a/sh.proc.c
+++ b/sh.proc.c
@@ -593,22 +593,44 @@ void
dowait(Char **v, struct command *c)
{
struct process *pp;
+
+ /* the current block mask to be able to restore */
+ sigset_t old_mask;
+
+ /* block mask for critical section: OLD_MASK U {SIGCHLD} */
+ sigset_t block_mask;
+
+ /* ignore those during blocking sigsuspend:
+ OLD_MASK / {SIGCHLD, possibly(SIGINT)} */
sigset_t pause_mask;
+
int opintr_disabled, gotsig;
USE(c);
USE(v);
pjobs++;
+
sigprocmask(SIG_BLOCK, NULL, &pause_mask);
sigdelset(&pause_mask, SIGCHLD);
if (setintr)
sigdelset(&pause_mask, SIGINT);
+
+ /* critical section, block also SIGCHLD */
+ sigprocmask(SIG_BLOCK, NULL, &block_mask);
+ sigaddset(&block_mask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &block_mask, &old_mask);
+
+ /* detect older SIGCHLDs and remove PRUNNING flag from proclist */
+ (void)handle_pending_signals();
+
loop:
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_procid && /* pp->p_procid == pp->p_jobid && */
pp->p_flags & PRUNNING) {
- (void)handle_pending_signals();
+ /* wait for (or pick up alredy blocked) SIGCHLD */
sigsuspend(&pause_mask);
+
+ /* make the 'wait' interuptable by CTRL-C */
opintr_disabled = pintr_disabled;
pintr_disabled = 0;
gotsig = handle_pending_signals();
@@ -618,6 +640,8 @@ loop:
goto loop;
}
pjobs = 0;
+
+ sigprocmask(SIG_SETMASK, &old_mask, NULL);
}
/*
--
2.1.0

View File

@ -3,7 +3,7 @@
Summary: An enhanced version of csh, the C shell
Name: tcsh
Version: 6.18.01
Release: 5%{?dist}
Release: 6%{?dist}
License: BSD
Group: System Environment/Shells
Source: http://ftp.funet.fi/pub/unix/shells/tcsh/%{name}-%{version}.tar.gz
@ -25,6 +25,11 @@ Patch34: tcsh-6.18.01-repeated-words-man.patch
# Proposed upstream - http://mx.gw.com/pipermail/tcsh-bugs/2013-April/000833.html
Patch35: tcsh-6.18.01-elf-interpreter.patch
# wait hang fix
# ~> #1181685
# ~> upstream: git diff 9178ceb5..0d8de594
Patch36: tcsh-6.18.01-wait-hang.patch
Provides: csh = %{version}
Requires(post): grep
Requires(postun): coreutils, grep
@ -55,6 +60,7 @@ like syntax.
%patch33 -p1 -b .history-merge
%patch34 -p1 -b .repeated-words-man
%patch35 -p1 -b .elf-interpreter
%patch36 -p1 -b .wait-hang
for i in Fixes WishList; do
iconv -f iso-8859-1 -t utf-8 "$i" > "${i}_" && \
@ -128,6 +134,9 @@ fi
%{_mandir}/man1/*.1*
%changelog
* Tue Jan 27 2015 Pavel Raiskup <praiskup@redhat.com> - 6.18.01-6
- fix 'wait' built-in hang (#1181685)
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 6.18.01-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild