last parts of Coherent patchkit: O_ACCMODE and termio
This commit is contained in:
parent
fef3808126
commit
e6ace01f12
5
Build.sh
5
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.561 2012/05/04 22:04:58 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.562 2012/05/04 22:18:22 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012
|
# 2011, 2012
|
||||||
@ -1307,6 +1307,7 @@ ac_header paths.h
|
|||||||
ac_header stdint.h stdarg.h
|
ac_header stdint.h stdarg.h
|
||||||
# include strings.h only if compatible with string.h
|
# include strings.h only if compatible with string.h
|
||||||
ac_header strings.h sys/types.h string.h
|
ac_header strings.h sys/types.h string.h
|
||||||
|
ac_header termios.h
|
||||||
ac_header ulimit.h sys/types.h
|
ac_header ulimit.h sys/types.h
|
||||||
ac_header values.h
|
ac_header values.h
|
||||||
|
|
||||||
@ -1409,7 +1410,7 @@ else
|
|||||||
#define EXTERN
|
#define EXTERN
|
||||||
#define MKSH_INCLUDES_ONLY
|
#define MKSH_INCLUDES_ONLY
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.561 2012/05/04 22:04:58 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.562 2012/05/04 22:18:22 tg Exp $");
|
||||||
int main(void) { printf("Hello, World!\n"); return (0); }
|
int main(void) { printf("Hello, World!\n"); return (0); }
|
||||||
EOF
|
EOF
|
||||||
case $cm in
|
case $cm in
|
||||||
|
12
edit.c
12
edit.c
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.235 2012/05/04 20:49:01 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.236 2012/05/04 22:18:23 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -3274,7 +3274,7 @@ x_mode(bool onoff)
|
|||||||
if (edchars.quit >= 0)
|
if (edchars.quit >= 0)
|
||||||
bind_if_not_bound(0, edchars.quit, XFUNC_noop);
|
bind_if_not_bound(0, edchars.quit, XFUNC_noop);
|
||||||
} else
|
} else
|
||||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
mksh_tcset(tty_fd, &tty_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !MKSH_S_NOVI
|
#if !MKSH_S_NOVI
|
||||||
@ -5369,12 +5369,12 @@ vi_macro_reset(void)
|
|||||||
#endif /* !MKSH_NO_CMDLINE_EDITING */
|
#endif /* !MKSH_NO_CMDLINE_EDITING */
|
||||||
|
|
||||||
void
|
void
|
||||||
x_mkraw(int fd, struct termios *ocb, bool forread)
|
x_mkraw(int fd, mksh_ttyst *ocb, bool forread)
|
||||||
{
|
{
|
||||||
struct termios cb;
|
mksh_ttyst cb;
|
||||||
|
|
||||||
if (ocb)
|
if (ocb)
|
||||||
tcgetattr(fd, ocb);
|
mksh_tcget(fd, ocb);
|
||||||
else
|
else
|
||||||
ocb = &tty_state;
|
ocb = &tty_state;
|
||||||
|
|
||||||
@ -5396,5 +5396,5 @@ x_mkraw(int fd, struct termios *ocb, bool forread)
|
|||||||
cb.c_cc[VTIME] = 0;
|
cb.c_cc[VTIME] = 0;
|
||||||
cb.c_cc[VMIN] = 1;
|
cb.c_cc[VMIN] = 1;
|
||||||
|
|
||||||
tcsetattr(fd, TCSADRAIN, &cb);
|
mksh_tcset(fd, &cb);
|
||||||
}
|
}
|
||||||
|
6
funcs.c
6
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.217 2012/05/04 22:05:00 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.218 2012/05/04 22:18:24 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -1783,7 +1783,7 @@ c_read(const char **wp)
|
|||||||
const char *ccp;
|
const char *ccp;
|
||||||
XString xs;
|
XString xs;
|
||||||
ptrdiff_t xsave = 0;
|
ptrdiff_t xsave = 0;
|
||||||
struct termios tios;
|
mksh_ttyst tios;
|
||||||
bool restore_tios = false;
|
bool restore_tios = false;
|
||||||
#if HAVE_SELECT
|
#if HAVE_SELECT
|
||||||
bool hastimeout = false;
|
bool hastimeout = false;
|
||||||
@ -2160,7 +2160,7 @@ c_read(const char **wp)
|
|||||||
afree(allocd, ATEMP);
|
afree(allocd, ATEMP);
|
||||||
Xfree(xs, xp);
|
Xfree(xs, xp);
|
||||||
if (restore_tios)
|
if (restore_tios)
|
||||||
tcsetattr(fd, TCSADRAIN, &tios);
|
mksh_tcset(fd, &tios);
|
||||||
return (rv);
|
return (rv);
|
||||||
#undef is_ifsws
|
#undef is_ifsws
|
||||||
}
|
}
|
||||||
|
18
jobs.c
18
jobs.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.86 2012/05/04 21:48:29 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.87 2012/05/04 22:18:25 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
#define mksh_killpg killpg
|
#define mksh_killpg killpg
|
||||||
@ -89,7 +89,7 @@ struct job {
|
|||||||
int32_t age; /* number of jobs started */
|
int32_t age; /* number of jobs started */
|
||||||
Coproc_id coproc_id; /* 0 or id of coprocess output pipe */
|
Coproc_id coproc_id; /* 0 or id of coprocess output pipe */
|
||||||
#ifndef MKSH_UNEMPLOYED
|
#ifndef MKSH_UNEMPLOYED
|
||||||
struct termios ttystat; /* saved tty state for stopped jobs */
|
mksh_ttyst ttystat; /* saved tty state for stopped jobs */
|
||||||
pid_t saved_ttypgrp; /* saved tty process group for stopped jobs */
|
pid_t saved_ttypgrp; /* saved tty process group for stopped jobs */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -333,7 +333,7 @@ j_change(void)
|
|||||||
warningf(false, "%s: %s", "warning",
|
warningf(false, "%s: %s", "warning",
|
||||||
"won't have full job control");
|
"won't have full job control");
|
||||||
if (tty_fd >= 0)
|
if (tty_fd >= 0)
|
||||||
tcgetattr(tty_fd, &tty_state);
|
mksh_tcget(tty_fd, &tty_state);
|
||||||
} else {
|
} else {
|
||||||
ttypgrp_ok = false;
|
ttypgrp_ok = false;
|
||||||
if (Flag(FTALKING))
|
if (Flag(FTALKING))
|
||||||
@ -803,14 +803,14 @@ j_resume(const char *cp, int bg)
|
|||||||
/* attach tty to job */
|
/* attach tty to job */
|
||||||
if (j->state == PRUNNING) {
|
if (j->state == PRUNNING) {
|
||||||
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
|
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
|
||||||
tcsetattr(tty_fd, TCSADRAIN, &j->ttystat);
|
mksh_tcset(tty_fd, &j->ttystat);
|
||||||
/* See comment in j_waitj regarding saved_ttypgrp. */
|
/* See comment in j_waitj regarding saved_ttypgrp. */
|
||||||
if (ttypgrp_ok &&
|
if (ttypgrp_ok &&
|
||||||
tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ?
|
tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ?
|
||||||
j->saved_ttypgrp : j->pgrp) < 0) {
|
j->saved_ttypgrp : j->pgrp) < 0) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
if (j->flags & JF_SAVEDTTY)
|
if (j->flags & JF_SAVEDTTY)
|
||||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
mksh_tcset(tty_fd, &tty_state);
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
bi_errorf("%s %s(%d, %ld) %s: %s",
|
bi_errorf("%s %s(%d, %ld) %s: %s",
|
||||||
"1st", "tcsetpgrp", tty_fd,
|
"1st", "tcsetpgrp", tty_fd,
|
||||||
@ -832,7 +832,7 @@ j_resume(const char *cp, int bg)
|
|||||||
if (!bg) {
|
if (!bg) {
|
||||||
j->flags &= ~JF_FG;
|
j->flags &= ~JF_FG;
|
||||||
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
|
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
|
||||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
mksh_tcset(tty_fd, &tty_state);
|
||||||
if (ttypgrp_ok && tcsetpgrp(tty_fd, kshpgrp) < 0)
|
if (ttypgrp_ok && tcsetpgrp(tty_fd, kshpgrp) < 0)
|
||||||
warningf(true, "%s %s(%d, %ld) %s: %s",
|
warningf(true, "%s %s(%d, %ld) %s: %s",
|
||||||
"fg: 2nd", "tcsetpgrp", tty_fd,
|
"fg: 2nd", "tcsetpgrp", tty_fd,
|
||||||
@ -1130,7 +1130,7 @@ j_waitj(Job *j,
|
|||||||
(long)kshpgrp, "failed", strerror(errno));
|
(long)kshpgrp, "failed", strerror(errno));
|
||||||
if (j->state == PSTOPPED) {
|
if (j->state == PSTOPPED) {
|
||||||
j->flags |= JF_SAVEDTTY;
|
j->flags |= JF_SAVEDTTY;
|
||||||
tcgetattr(tty_fd, &j->ttystat);
|
mksh_tcget(tty_fd, &j->ttystat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1146,9 +1146,9 @@ j_waitj(Job *j,
|
|||||||
*/
|
*/
|
||||||
if (j->state == PEXITED && j->status == 0 &&
|
if (j->state == PEXITED && j->status == 0 &&
|
||||||
(j->flags & JF_USETTYMODE)) {
|
(j->flags & JF_USETTYMODE)) {
|
||||||
tcgetattr(tty_fd, &tty_state);
|
mksh_tcget(tty_fd, &tty_state);
|
||||||
} else {
|
} else {
|
||||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
mksh_tcset(tty_fd, &tty_state);
|
||||||
/*-
|
/*-
|
||||||
* Don't use tty mode if job is stopped and
|
* Don't use tty mode if job is stopped and
|
||||||
* later restarted and exits. Consider
|
* later restarted and exits. Consider
|
||||||
|
4
main.c
4
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.219 2012/05/04 21:47:02 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.220 2012/05/04 22:18:26 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -1076,7 +1076,7 @@ tty_init(bool init_ttystate, bool need_tty)
|
|||||||
close(tty_fd);
|
close(tty_fd);
|
||||||
tty_fd = -1;
|
tty_fd = -1;
|
||||||
} else if (init_ttystate)
|
} else if (init_ttystate)
|
||||||
tcgetattr(tty_fd, &tty_state);
|
mksh_tcget(tty_fd, &tty_state);
|
||||||
if (do_close)
|
if (do_close)
|
||||||
close(tfd);
|
close(tfd);
|
||||||
}
|
}
|
||||||
|
25
sh.h
25
sh.h
@ -79,7 +79,12 @@
|
|||||||
#if HAVE_STRINGS_H
|
#if HAVE_STRINGS_H
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_TERMIOS_H
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#else
|
||||||
|
/* shudder */
|
||||||
|
#include <termio.h>
|
||||||
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if HAVE_ULIMIT_H
|
#if HAVE_ULIMIT_H
|
||||||
#include <ulimit.h>
|
#include <ulimit.h>
|
||||||
@ -152,7 +157,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.556 2012/05/04 22:05:02 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.557 2012/05/04 22:18:27 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R40 2012/04/27"
|
#define MKSH_VERSION "R40 2012/04/27"
|
||||||
|
|
||||||
@ -350,6 +355,10 @@ extern int __cdecl setegid(gid_t);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__COHERENT__)
|
#if defined(__COHERENT__)
|
||||||
|
#ifndef O_ACCMODE
|
||||||
|
/* this need not work everywhere, take care */
|
||||||
|
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
|
||||||
|
#endif
|
||||||
#define mksh_TIME(tv) do { \
|
#define mksh_TIME(tv) do { \
|
||||||
(tv).tv_usec = 0; \
|
(tv).tv_usec = 0; \
|
||||||
(tv).tv_sec = time(NULL); \
|
(tv).tv_sec = time(NULL); \
|
||||||
@ -366,6 +375,16 @@ extern int __cdecl setegid(gid_t);
|
|||||||
#define mksh_lstat lstat
|
#define mksh_lstat lstat
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_TERMIOS_H
|
||||||
|
#define mksh_ttyst struct termios
|
||||||
|
#define mksh_tcget(fd,st) tcgetattr((fd), (st))
|
||||||
|
#define mksh_tcset(fd,st) tcsetattr((fd), TCSADRAIN, (st))
|
||||||
|
#else
|
||||||
|
#define mksh_ttyst struct termio
|
||||||
|
#define mksh_tcget(fd,st) ioctl((fd), TCGETA, (st))
|
||||||
|
#define mksh_tcset(fd,st) ioctl((fd), TCSETAW, (st))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* remove redundancies */
|
/* remove redundancies */
|
||||||
|
|
||||||
#if defined(MirBSD) && (MirBSD >= 0x08A8) && !defined(MKSH_OPTSTATIC)
|
#if defined(MirBSD) && (MirBSD >= 0x08A8) && !defined(MKSH_OPTSTATIC)
|
||||||
@ -1569,7 +1588,7 @@ int x_bind(const char *, const char *, bool);
|
|||||||
void x_init(void);
|
void x_init(void);
|
||||||
int x_read(char *, size_t);
|
int x_read(char *, size_t);
|
||||||
#endif
|
#endif
|
||||||
void x_mkraw(int, struct termios *, bool);
|
void x_mkraw(int, mksh_ttyst *, bool);
|
||||||
/* eval.c */
|
/* eval.c */
|
||||||
char *substitute(const char *, int);
|
char *substitute(const char *, int);
|
||||||
char **eval(const char **, int);
|
char **eval(const char **, int);
|
||||||
@ -1955,7 +1974,7 @@ int test_parse(Test_env *);
|
|||||||
|
|
||||||
EXTERN int tty_fd E_INIT(-1); /* dup'd tty file descriptor */
|
EXTERN int tty_fd E_INIT(-1); /* dup'd tty file descriptor */
|
||||||
EXTERN bool tty_devtty; /* true if tty_fd is from /dev/tty */
|
EXTERN bool tty_devtty; /* true if tty_fd is from /dev/tty */
|
||||||
EXTERN struct termios tty_state; /* saved tty state */
|
EXTERN mksh_ttyst tty_state; /* saved tty state */
|
||||||
|
|
||||||
extern void tty_init(bool, bool);
|
extern void tty_init(bool, bool);
|
||||||
extern void tty_close(void);
|
extern void tty_close(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user