Ray.Nickson@comp.vuw.ac.nz (Ray Nickson) (11/16/89)
I finally got around to doing the work necessary to get bash to do job
control under HPUX, recent versions of which do have BSD-compatible
process group handling. I've done this via new #defines in config.h,
so if Brian uses the fixes, old HPUX users can just edit them out of
config.h. Patches follow.
-rgn
--
Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand.
Ray.Nickson@comp.vuw.ac.nz + 64 4 721000x8593
*** config.h.orig Fri Sep 22 12:41:17 1989
--- config.h Wed Nov 15 15:35:10 1989
***************
*** 25,44 ****
#define SYSV
#endif
/* Define NO_DUP2 if your OS doesn't have a dup2 () call. */
! #ifdef hpux
#define NO_DUP2
#endif
/* Define JOB_CONTROL if your operating system supports
BSD-like job control. */
#define JOB_CONTROL
/* Note that System V machines don't support job control. */
! #if defined (SYSV) && !defined (HP9KS300)
#undef JOB_CONTROL
! #endif /* SYSV && !HP9KS300 */
/* Define ALIAS if you want the alias features. */
#define ALIAS
--- 25,64 ----
#define SYSV
#endif
+ /* for glob.c */
+ #ifdef SYSV
+ #define USG
+ #endif
+
/* Define NO_DUP2 if your OS doesn't have a dup2 () call. */
! #ifdef notdef /* hpux does! */
#define NO_DUP2
#endif
+ /* define TERMIO if you have SYSV style ioctl in termio.h */
+ #ifdef SYSV
+ #define TERMIO
+ #endif
+
+ /* define BSDTTY if you have BSD tty process group emulation in bsdtty.h */
+ #ifdef hpux
+ #define BSDTTY
+ #endif
+
/* Define JOB_CONTROL if your operating system supports
BSD-like job control. */
#define JOB_CONTROL
/* Note that System V machines don't support job control. */
! #if defined (SYSV) && !defined (HPUX)
#undef JOB_CONTROL
! #endif /* SYSV && !HPUX */
+ /* Define RUSAGE if your system has a wait3() that knows about rusage */
+ #if defined (Bsd)
+ #define RUSAGE
+ #endif
+
/* Define ALIAS if you want the alias features. */
#define ALIAS
***************
*** 66,72 ****
/* Define NO_WAIT_H if your system doesn't seem to have sys/wait.h.
This is true for HPUX and ALTOS. */
! #if defined (HPUX) || defined (ALTOS)
#define NO_WAIT_H
#endif
--- 86,92 ----
/* Define NO_WAIT_H if your system doesn't seem to have sys/wait.h.
This is true for HPUX and ALTOS. */
! #if defined (ALTOS) /* || defined (HPUX) hpux does have it. */
#define NO_WAIT_H
#endif
*** jobs.c.orig Sun Nov 5 05:54:16 1989
--- jobs.c Wed Nov 15 15:38:38 1989
***************
*** 28,41 ****
--- 28,59 ----
#include <signal.h>
#include <errno.h>
#include <sys/time.h>
+ #include <sys/types.h>
+ #ifdef RUSAGE
#include <sys/resource.h>
+ #endif
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/param.h>
+ #ifdef TERMIO
+ #include <termio.h>
+ #ifdef BSDTTY
+ #include <bsdtty.h>
+ #endif
+ #else
#include <sgtty.h>
+ #endif
#include "shell.h"
#include "jobs.h"
+ #ifdef TERMIO
+ /* SYSV names for BSD ioctl things */
+ #define sgttyb termio
+ #define TIOCGETP TCGETA
+ #define TIOCSETP TCSETA
+ #define TIOCSETN TCSETA
+ #endif
+
/* Not all systems define errno in errno.h. */
extern int errno;
***************
*** 1185,1203 ****
int sig, code;
{
union wait status;
struct rusage rusage;
PROCESS *child;
int pid;
do
{
pid = wait3 (&status, (WNOHANG | WUNTRACED), &rusage);
!
if (pid > 0)
{
/* Keep track of total time used. */
if (! WIFSTOPPED (status))
add_times (&rusage);
/* Locate our PROCESS for this pid. */
child = find_pipeline (pid);
--- 1203,1229 ----
int sig, code;
{
union wait status;
+ #ifdef RUSAGE
struct rusage rusage;
+ #endif
PROCESS *child;
int pid;
do
{
+ #ifdef RUSAGE
pid = wait3 (&status, (WNOHANG | WUNTRACED), &rusage);
! #else
! /* hpux has wait3() but not rusage; what do other systems do? */
! pid = wait3 (&status, (WNOHANG | WUNTRACED), NULL);
! #endif
if (pid > 0)
{
/* Keep track of total time used. */
+ #ifdef RUSAGE
if (! WIFSTOPPED (status))
add_times (&rusage);
+ #endif
/* Locate our PROCESS for this pid. */
child = find_pipeline (pid);
***************
*** 1332,1337 ****
--- 1358,1366 ----
sigsetmask (oldmask);
}
+ #ifdef RUSAGE
+ /* If we don't have rusage, we can't gather these statistics this way.
+ Do we need them? */
add_times (rused)
struct rusage *rused;
{
***************
*** 1356,1361 ****
--- 1385,1391 ----
user_seconds_used = (total_usertime.tv_sec % 60);
}
}
+ #endif
/* Initialize the job control mechanism, and set up the tty stuff. */
initialize_jobs ()
***************
*** 1387,1393 ****
/* Find the highest unused file descriptor we can. */
{
! int ignore, nds = getdtablesize ();
while (--nds > 3)
{
--- 1417,1428 ----
/* Find the highest unused file descriptor we can. */
{
! int ignore;
! #ifdef _NFILE
! int nds = _NFILE;
! #else
! int nds = getdtablesize ();
! #endif
while (--nds > 3)
{
***************
*** 1417,1422 ****
--- 1452,1458 ----
break;
}
+ #ifdef TIOCGETD /* what we don't know, can't hurt */
if (ioctl (shell_tty, TIOCGETD, &ldisc) < 0)
goto bad_ioctl;
***************
*** 1432,1437 ****
--- 1468,1474 ----
file_error ("jobs.c");
}
}
+ #endif
original_pgrp = shell_pgrp;
shell_pgrp = getpid ();
***************
*** 1438,1445 ****
--- 1475,1485 ----
give_terminal_to (shell_pgrp);
setpgrp (0, shell_pgrp);
+ #ifdef FIOCLEX
+ /* sorry, I don't know the hpux/sysv equivalent. */
if (shell_tty != fileno (stdin))
ioctl (shell_tty, FIOCLEX, 0);
+ #endif
job_control = 1;
}
*** jobs.h.orig Mon Aug 21 14:29:49 1989
--- jobs.h Fri Nov 10 14:49:11 1989
***************
*** 2,8 ****
#include "quit.h"
! #if !defined (SYSV) || defined (UNIXPC)
#include <sys/wait.h>
#else
--- 2,8 ----
#include "quit.h"
! #ifndef NO_WAIT_H
#include <sys/wait.h>
#else
*** shell.c.orig Wed Nov 8 10:56:45 1989
--- shell.c Wed Nov 8 10:57:48 1989
***************
*** 669,675 ****
--- 669,679 ----
{
/* Line buffer output for stderr. */
+ #ifdef Bsd
+ setlinebuf (stderr);
+ #else
setvbuf (stderr, (char *)NULL, _IOLBF, BUFSIZ);
+ #endif
/* The initialization of the basic underlying signal handlers must
happen before we initialize_traps (). */
*** siglist.c.orig Thu Jul 27 01:02:05 1989
--- siglist.c Wed Nov 15 16:33:13 1989
***************
*** 19,24 ****
--- 19,25 ----
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
char *sys_siglist[] = {
+ #ifndef HPUX
"bogus signal", /* 0 */
"hangup", /* 1 SIGHUP */
"interrupt", /* 2 SIGINT */
***************
*** 43,47 ****
"profiling timer alarm", /* 21 SIGPROF */
"asynchronous I/O", /* 22 SIGIO */
"window change or mouse signal", /* 23 SIGWINDOW */
(char *)0x0
! };
--- 44,81 ----
"profiling timer alarm", /* 21 SIGPROF */
"asynchronous I/O", /* 22 SIGIO */
"window change or mouse signal", /* 23 SIGWINDOW */
+ #else HPUX
+ "Signal 0", /* 0 */
+ "Hangup", /* 1 */
+ "Interrupt", /* 2 */
+ "Quit", /* 3 */
+ "Illegal instruction", /* 4 */
+ "Trace/BPT trap", /* 5 */
+ "IOT trap", /* 6 */
+ "EMT trap", /* 7 */
+ "Floating point exception", /* 8 */
+ "Killed", /* 9 */
+ "Bus error", /* 10 */
+ "Segmentation fault", /* 11 */
+ "Bad system call", /* 12 */
+ "Broken pipe", /* 13 */
+ "Alarm clock", /* 14 */
+ "Terminated", /* 15 */
+ "User defined signal 1", /* 16 */
+ "User defined signal 2", /* 17 */
+ "Child exited", /* 18 */
+ "Power failure restart", /* 19 */
+ "Virtual timer expired", /* 20 */
+ "Profiling timer expired", /* 21 */
+ "I/O possible", /* 22 */
+ "Window changed", /* 23 */
+ "Stopped (signal)", /* 24 */
+ "Stopped", /* 25 */
+ "Continued", /* 26 */
+ "Stopped (tty input)", /* 27 */
+ "Stopped (tty output)", /* 28 */
+ "Urgent I/O condition", /* 29 */
+ #endif
(char *)0x0
! };
!
*** trap.c.orig Sun Aug 6 03:27:10 1989
--- trap.c Wed Nov 15 16:37:55 1989
***************
*** 60,65 ****
--- 60,77 ----
"SIGUSR2",
"SIGCLD",
"SIGPWR",
+ #ifdef HPUX
+ "SIGVTALRM",
+ "SIGPROF",
+ "SIGIO",
+ "SIGWINDOW",
+ "SIGSTOP",
+ "SIGTSTP",
+ "SIGCONT",
+ "SIGTTIN",
+ "SIGTTOU",
+ "SIGURG"
+ #endif
#if NSIG == 23
"SIGJUNK1",
"SIGJUNK2",