mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
The fault.c and edit.c changes in this commit were inspired by changes in the 93v- beta but take a slightly different approach: mainly, the code to update $COLUMNS and $LINES is put in its own function instead of duplicated in sh_chktrap() and ed_setup(). src/cmd/ksh93/sh/fault.c: - Move code to update $COLUMNS and $LINES to a new sh_update_columns_lines() function so it can be reused. - Fix compile error on systems without SIGWINCH. src/cmd/ksh93/edit/edit.c: - ed_setup(): Call sh_update_columns_lines() instead of issuing SIGWINCH to self. - Change two sh_fault(SIGINT) calls to issuing the signal to the current process using kill(2). sh_fault() is now never called directly (as in the 93v- beta). src/cmd/ksh93/sh/main.c: sh_main(): - On non-interactive, call sh_update_columns_lines() and set the signal handler for SIGWINCH to sh_fault(), causing $COLUMNS and $LINES to be kept up to date when the terminal window is resized (this is handled elsewhere for interactive shells). This change makes ksh act like mksh, bash and zsh. (Previously, ksh required setting a dummy SIGWINCH trap to get auto-updated $COLUMNS and $LINES in scripts, as this set the SIGWINCH signal handler to sh_fault(). This persisted even after unsetting the trap again, so that was inconsistent behaviour.) src/cmd/ksh93/include/shell.h: - Don't define sh.winch on systems without SIGWINCH. src/cmd/ksh93/sh.1: - Update and tweak the COLUMNS and LINES variable documentation. - Move them up to the section of variables that are set by the shell (which AT&T should have done before).
131 lines
3.9 KiB
C
131 lines
3.9 KiB
C
/***********************************************************************
|
|
* *
|
|
* This software is part of the ast package *
|
|
* Copyright (c) 1982-2011 AT&T Intellectual Property *
|
|
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
|
|
* and is licensed under the *
|
|
* Eclipse Public License, Version 1.0 *
|
|
* by AT&T Intellectual Property *
|
|
* *
|
|
* A copy of the License is available at *
|
|
* http://www.eclipse.org/org/documents/epl-v10.html *
|
|
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
|
* *
|
|
* Information and Software Systems Research *
|
|
* AT&T Research *
|
|
* Florham Park NJ *
|
|
* *
|
|
* David Korn <dgk@research.att.com> *
|
|
* *
|
|
***********************************************************************/
|
|
#ifndef SH_SIGBITS
|
|
/*
|
|
* UNIX shell
|
|
* S. R. Bourne
|
|
* Rewritten by David Korn
|
|
*
|
|
*/
|
|
|
|
#include <sig.h>
|
|
#include <setjmp.h>
|
|
#include <error.h>
|
|
#include <sfio.h>
|
|
#include "FEATURE/setjmp"
|
|
#include "FEATURE/sigfeatures"
|
|
|
|
|
|
#ifndef SIGWINCH
|
|
# ifdef SIGWIND
|
|
# define SIGWINCH SIGWIND
|
|
# else
|
|
# ifdef SIGWINDOW
|
|
# define SIGWINCH SIGWINDOW
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
typedef void (*SH_SIGTYPE)(int,void(*)(int));
|
|
|
|
#define SH_FORKLIM 16 /* fork timeout interval */
|
|
|
|
#define SH_TRAP 0200 /* bit for internal traps */
|
|
#define SH_ERRTRAP 0 /* trap for non-zero exit status */
|
|
#define SH_KEYTRAP 1 /* trap for keyboard event */
|
|
#define SH_DEBUGTRAP 4 /* must be last internal trap */
|
|
|
|
#define SH_SIGBITS 8
|
|
#define SH_SIGFAULT 1 /* signal handler is sh_fault */
|
|
#define SH_SIGOFF 2 /* signal handler is SIG_IGN */
|
|
#define SH_SIGSET 4 /* pending signal */
|
|
#define SH_SIGTRAP 010 /* pending trap */
|
|
#define SH_SIGDONE 020 /* default is exit */
|
|
#define SH_SIGIGNORE 040 /* default is ignore signal */
|
|
#define SH_SIGINTERACTIVE 0100 /* handle interactive specially */
|
|
#define SH_SIGTSTP 0200 /* tstp signal received */
|
|
#define SH_SIGTERM SH_SIGOFF /* term signal received */
|
|
#define SH_SIGRUNTIME 0400 /* runtime value */
|
|
|
|
#define SH_SIGRTMIN 0 /* sh.sigruntime[] index */
|
|
#define SH_SIGRTMAX 1 /* sh.sigruntime[] index */
|
|
|
|
/*
|
|
* These are longjmp values
|
|
*/
|
|
|
|
#define SH_JMPDOT 2
|
|
#define SH_JMPEVAL 3
|
|
#define SH_JMPTRAP 4
|
|
#define SH_JMPIO 5
|
|
#define SH_JMPCMD 6
|
|
#define SH_JMPFUN 7
|
|
#define SH_JMPERRFN 8
|
|
#define SH_JMPSUB 9
|
|
#define SH_JMPERREXIT 10
|
|
#define SH_JMPEXIT 11
|
|
#define SH_JMPSCRIPT 12
|
|
|
|
struct openlist
|
|
{
|
|
Sfio_t *strm;
|
|
struct openlist *next;
|
|
};
|
|
|
|
struct checkpt
|
|
{
|
|
sigjmp_buf buff;
|
|
sigjmp_buf *prev;
|
|
int topfd;
|
|
int mode;
|
|
struct openlist *olist;
|
|
Error_context_t err;
|
|
};
|
|
|
|
#define sh_pushcontext(bp,n) \
|
|
( \
|
|
(bp)->mode = (n), \
|
|
(bp)->olist = 0, \
|
|
(bp)->topfd = sh.topfd, \
|
|
(bp)->prev = sh.jmplist, \
|
|
(bp)->err = *ERROR_CONTEXT_BASE, \
|
|
sh.jmplist = (sigjmp_buf*)(&(bp)->buff) \
|
|
)
|
|
#define sh_popcontext(bp) \
|
|
( \
|
|
sh.jmplist = (bp)->prev, \
|
|
errorpop(&((bp)->err)) \
|
|
)
|
|
|
|
extern noreturn void sh_done(int);
|
|
extern void sh_fault(int);
|
|
extern void sh_update_columns_lines(void);
|
|
extern void sh_sigclear(int);
|
|
extern void sh_sigdone(void);
|
|
extern void sh_siginit(void);
|
|
extern void sh_sigtrap(int);
|
|
extern void sh_sigreset(int);
|
|
extern void *sh_timeradd(unsigned long,int ,void (*)(void*),void*);
|
|
extern void timerdel(void*);
|
|
|
|
extern const char e_alarm[];
|
|
|
|
#endif /* !SH_SIGBITS */
|