summaryrefslogtreecommitdiff
path: root/jobs.h
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>1996-12-23 17:02:34 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:49 +0000
commitccc6cda312fea9f0468ee65b8f368e9653e1380b (patch)
treeb059878adcfd876c4acb8030deda1eeb918c7e75 /jobs.h
parent726f63884db0132f01745f1fb4465e6621088ccf (diff)
downloadbash-ccc6cda312fea9f0468ee65b8f368e9653e1380b.tar.gz
Imported from ../bash-2.0.tar.gz.
Diffstat (limited to 'jobs.h')
-rw-r--r--jobs.h190
1 files changed, 43 insertions, 147 deletions
diff --git a/jobs.h b/jobs.h
index 18d3d736..f80047e1 100644
--- a/jobs.h
+++ b/jobs.h
@@ -18,8 +18,8 @@
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-#if !defined (__JOBS_H__)
-# define __JOBS_H__
+#if !defined (_JOBS_H_)
+# define _JOBS_H_
#include "quit.h"
#include "siglist.h"
@@ -27,93 +27,26 @@
#include "stdc.h"
/* Defines controlling the fashion in which jobs are listed. */
-#define JLIST_STANDARD 0
-#define JLIST_LONG 1
-#define JLIST_PID_ONLY 2
-#define JLIST_CHANGED_ONLY 3
-
-#if defined (HAVE_WAIT_H)
+#define JLIST_STANDARD 0
+#define JLIST_LONG 1
+#define JLIST_PID_ONLY 2
+#define JLIST_CHANGED_ONLY 3
+#define JLIST_NONINTERACTIVE 4
+
+/* If _POSIX_VERSION is not defined, we assume that <sys/wait.h> defines
+ a `union wait' and various macros used to manipulate it. Look in
+ bashwait.h for the things we expect to find. */
+#if defined (HAVE_SYS_WAIT_H)
# include <sys/wait.h>
-#else /* !HAVE_WAIT_H */
-
-# include "bash_endian.h"
-
+#else /* !HAVE_SYS_WAIT_H */
# if !defined (_POSIX_VERSION)
-# if defined (LITTLE_ENDIAN)
-union wait
- {
- int w_status; /* used in syscall */
-
- /* Terminated process status. */
- struct
- {
- unsigned short
- w_Termsig : 7, /* termination signal */
- w_Coredump : 1, /* core dump indicator */
- w_Retcode : 8, /* exit code if w_termsig==0 */
- w_Fill1 : 16; /* high 16 bits unused */
- } w_T;
-
- /* Stopped process status. Returned
- only for traced children unless requested
- with the WUNTRACED option bit. */
- struct
- {
- unsigned short
- w_Stopval : 8, /* == W_STOPPED if stopped */
- w_Stopsig : 8, /* actually zero on XENIX */
- w_Fill2 : 16; /* high 16 bits unused */
- } w_S;
- };
-
-# else /* !LITTLE_ENDIAN */
-
-/* This is for big-endian machines like the IBM RT, HP 9000, or Sun-3 */
-
-union wait
- {
- int w_status; /* used in syscall */
-
- /* Terminated process status. */
- struct
- {
- unsigned short w_Fill1 : 16; /* high 16 bits unused */
- unsigned w_Retcode : 8; /* exit code if w_termsig==0 */
- unsigned w_Coredump : 1; /* core dump indicator */
- unsigned w_Termsig : 7; /* termination signal */
- } w_T;
-
- /* Stopped process status. Returned
- only for traced children unless requested
- with the WUNTRACED option bit. */
- struct
- {
- unsigned short w_Fill2 : 16; /* high 16 bits unused */
- unsigned w_Stopsig : 8; /* signal that stopped us */
- unsigned w_Stopval : 8; /* == W_STOPPED if stopped */
- } w_S;
- };
-
-# endif /* !LITTLE_ENDIAN */
-
-# define w_termsig w_T.w_Termsig
-# define w_coredump w_T.w_Coredump
-# define w_retcode w_T.w_Retcode
-# define w_stopval w_S.w_Stopval
-# define w_stopsig w_S.w_Stopsig
-
-/* Note that sys/wait.h defines these for Posix systems. */
-# define WSTOPPED 0177
-# define WIFSTOPPED(x) (((x) . w_stopval) == WSTOPPED)
-# define WIFEXITED(x) ((! (WIFSTOPPED (x))) && (((x) . w_termsig) == 0))
-# define WIFSIGNALED(x) ((! (WIFSTOPPED (x))) && (((x) . w_termsig) != 0))
-# endif /* !_POSIX_VERSION */
-#endif /* !HAVE_WAIT_H */
+# include "bashwait.h"
+# endif
+#endif /* !HAVE_SYS_WAIT_H */
/* How to get the status of a job. For Posix, this is just an
int, but for other systems we have to crack the union wait. */
#if !defined (_POSIX_VERSION)
-# define pid_t int
typedef union wait WAIT;
# define WSTATUS(t) (t.w_status)
#else /* _POSIX_VERSION */
@@ -200,10 +133,19 @@ typedef struct process {
typedef enum { JRUNNING, JSTOPPED, JDEAD, JMIXED } JOB_STATE;
#define JOBSTATE(job) (jobs[(job)]->state)
+#define STOPPED(j) (jobs[(j)]->state == JSTOPPED)
+#define RUNNING(j) (jobs[(j)]->state == JRUNNING)
+#define DEADJOB(j) (jobs[(j)]->state == JDEAD)
+
/* Values for the FLAGS field in the JOB struct below. */
#define J_FOREGROUND 0x01 /* Non-zero if this is running in the foreground. */
#define J_NOTIFIED 0x02 /* Non-zero if already notified about job state. */
#define J_JOBCONTROL 0x04 /* Non-zero if this job started under job control. */
+#define J_NOHUP 0x08 /* Don't send SIGHUP to job if shell gets SIGHUP. */
+
+#define IS_FOREGROUND(j) ((jobs[j]->flags & J_FOREGROUND) != 0)
+#define IS_NOTIFIED(j) ((jobs[j]->flags & J_NOTIFIED) != 0)
+#define IS_JOBCONTROL(j) ((jobs[j]->flags & J_JOBCONTROL) != 0)
typedef struct job {
char *wd; /* The working directory at time of invocation. */
@@ -213,6 +155,8 @@ typedef struct job {
int flags; /* Flags word: J_NOTIFIED, J_FOREGROUND, or J_JOBCONTROL. */
#if defined (JOB_CONTROL)
COMMAND *deferred; /* Commands that will execute when this job is done. */
+ VFunction *j_cleanup; /* Cleanup function to call when job marked JDEAD */
+ PTR_T cleanarg; /* Argument passed to (*j_cleanup)() */
#endif /* JOB_CONTROL */
} JOB;
@@ -222,69 +166,10 @@ typedef struct job {
/* A value which cannot be a process ID. */
#define NO_PID (pid_t)-1
-#if !defined (_POSIX_VERSION) && !defined (sigmask)
-# define sigmask(x) (1 << ((x)-1))
-#endif /* !POSIX && !sigmask */
-
-#if !defined (SIGABRT)
-# define SIGABRT SIGIOT
-#endif /* !SIGABRT */
-
-#if !defined (SIGCHLD)
-# define SIGCHLD SIGCLD
-#endif /* !SIGCHLD */
-
-#if !defined (_POSIX_VERSION)
-# if !defined (SIG_BLOCK)
-# define SIG_BLOCK 2
-# define SIG_SETMASK 3
-# endif /* SIG_BLOCK */
-
-/* Type of a signal set. */
-# define sigset_t int
-
-/* Make sure there is nothing inside the signal set. */
-# define sigemptyset(set) (*(set) = 0)
-
-/* Initialize the signal set to hold all signals. */
-# define sigfillset(set) (*set) = sigmask (NSIG) - 1
-
-/* Add SIG to the contents of SET. */
-# define sigaddset(set, sig) *(set) |= sigmask (sig)
-
-/* Delete SIG from signal set SET. */
-# define sigdelset(set, sig) *(set) &= ~sigmask (sig)
-
-/* Is SIG a member of the signal set SET? */
-# define sigismember(set, sig) ((*(set) & sigmask (sig)) != 0)
-
-/* Suspend the process until the reception of one of the signals
- not present in SET. */
-# define sigsuspend(set) sigpause (*(set))
-#endif /* !_POSIX_VERSION */
-
-/* These definitions are used both in POSIX and non-POSIX implementations. */
-
-#define BLOCK_SIGNAL(sig, nvar, ovar) \
- sigemptyset (&nvar); \
- sigaddset (&nvar, sig); \
- sigemptyset (&ovar); \
- sigprocmask (SIG_BLOCK, &nvar, &ovar)
-
-#if defined (_POSIX_VERSION)
-# define BLOCK_CHILD(nvar, ovar) \
- BLOCK_SIGNAL (SIGCHLD, nvar, ovar)
-# define UNBLOCK_CHILD(ovar) \
- sigprocmask (SIG_SETMASK, &ovar, (sigset_t *) NULL)
-#else /* !_POSIX_VERSION */
-# define BLOCK_CHILD(nvar, ovar) ovar = sigblock (sigmask (SIGCHLD))
-# define UNBLOCK_CHILD(ovar) sigsetmask (ovar)
-#endif /* !_POSIX_VERSION */
-
/* System calls. */
-#if !defined (SunOS5) && !defined (USGr4_2) && !defined (__BSD_4_4__)
+#if !defined (HAVE_UNISTD_H)
extern pid_t fork (), getpid (), getpgrp ();
-#endif /* !SunOS5 && !USGr4_2 && !__BSD_4_4__ */
+#endif /* !HAVE_UNISTD_H */
/* Stuff from the jobs.c file. */
extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp;
@@ -297,9 +182,12 @@ extern int job_slots;
extern void making_children __P((void));
extern void stop_making_children __P((void));
extern void cleanup_the_pipeline __P((void));
+extern void save_pipeline __P((int));
+extern void restore_pipeline __P((int));
extern void start_pipeline __P((void));
extern int stop_pipeline __P((int, COMMAND *));
extern void delete_job __P((int));
+extern void nohup_job __P((int));
extern void terminate_current_pipeline __P((void));
extern void terminate_stopped_jobs __P((void));
@@ -312,8 +200,10 @@ extern void describe_pid __P((int));
extern void describe_pid __P((pid_t));
#endif
-extern int list_one_job __P((JOB *, int, int, int));
-extern void list_jobs __P((int));
+extern void list_one_job __P((JOB *, int, int, int));
+extern void list_all_jobs __P((int));
+extern void list_stopped_jobs __P((int));
+extern void list_running_jobs __P((int));
extern pid_t make_child __P((char *, int));
extern int get_tty_state __P((void));
@@ -332,14 +222,20 @@ extern int initialize_jobs __P((void));
extern void initialize_job_signals __P((void));
extern int give_terminal_to __P((pid_t));
+extern void set_sigwinch_handler __P((void));
+extern void unset_sigwinch_handler __P((void));
+
+extern void unfreeze_jobs_list __P((void));
extern int set_job_control __P((int));
extern void without_job_control __P((void));
extern void end_job_control __P((void));
extern void restart_job_control __P((void));
extern void set_sigchld_handler __P((void));
+extern void ignore_tty_job_signals __P((void));
+extern void default_tty_job_signals __P((void));
#if defined (JOB_CONTROL)
extern int job_control;
#endif
-#endif /* __JOBS_H__ */
+#endif /* _JOBS_H_ */