summaryrefslogtreecommitdiffstats
path: root/bin/sh/jobs.c
Commit message (Collapse)AuthorAgeFilesLines
* Add the POSIX option -p to the jobs builtin command. It prints the PID of thestefanf2006-10-071-17/+23
| | | | | | | | process leader for each job. Now the last specified option for the output format (-l, -p or -s) wins, previously -s trumped -l. PR: 99926 Submitted by: Ed Schouten and novel (patches modified by me)
* Remove some white space at EOL.schweikh2006-02-041-2/+2
|
* o Now when SIG_IGN signal action for SIGCHLD reap zombiesmaxim2005-12-141-0/+2
| | | | | | | | | | | | automatically it is possible wait4(2) returns -1 and sets errno = ECHILD if there were forked children. A user can set such signal handler e.g. via ``trap "" 20'', see a PR for the test case. Deal with this case and mark a job as JOBDONE. PR: bin/90334 Submitted by: bde MFC after: 4 weeks
* Print pointers with %p rather than casting them to long.stefanf2005-09-051-2/+2
|
* o Terminate an endless loop sh -T goes into in dowait() around waitproc().maxim2004-12-021-1/+2
| | | | | | | | | | | | XXX from Tor: "The shell can also go into a similar loop if the child was killed by signal 127, since the shell would believe the child to have only stopped (WIFSTOPPED() macro returns nonzero value). Disallowing signals 127 and 128 will fix that problem." See kern/19402 for details. PR: bin/66242 Submitted by: tegge Analysis and testcase by: demon MFC after: 3 weeks
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* Commit fix sent by Tor Egge <Tor.Egge@cvsup.no.freebsd.org>cracauer2004-02-051-1/+1
| | | | | | | | | | Only use return value from system call if system call succeeded. Tested with `make world` and some of my own scripts. This should be MFCed soon. While /bin/sh is hard to test the fix is obviously correct and can be assumed not to break something else (famous last words...).
* Use sys_nsig instead of NSIG for the length of the signal arrays. Thisnjl2004-01-281-2/+2
| | | | | | | is important if we add new signals later. From DragonflyBSD: jobs.c:1.4, trap.c:1.3. Obtained from: DragonflyBSD
* Changes following CScout analysis:dds2003-07-051-4/+4
| | | | | | | | | | | - Removed dead declarations - Made objects that should have been declared as static, static. The changes use STATIC instead of static, following the existing convention in the rest of the code. Approved by: schweikh (mentor) MFC after: 2 weeks
* Flush the output buffers before forking a child process to avoidtjr2003-03-171-0/+1
| | | | | | | the child process writing data that the parent should have written. PR: 50051 MFC after: 2 weeks
* Ensure that the TTY file descriptor is greater than or equal to 10 so thattjr2003-01-271-1/+14
| | | | | | | it doesn't interfere with the user's redirections. PR: 47136 MFC after: 1 week
* Make this compile with DEBUG defined now that WARNS=0 has been removedtjr2003-01-211-1/+1
| | | | | | | | from the Makefile: - Print pointers with %p instead of %x. - Include missing headers to get prototypes. Noticed by: benno
* When job control is disabled, never show the job id when reporting thetjr2002-12-141-1/+2
| | | | status of a background process that has terminated because of a signal.
* Use the %t format modifier to print differences betweenmux2002-10-011-1/+1
| | | | | | | | | | | pointers. This fixes two format warnings on 64 bits archs which are fatal now that WFORMAT=0 has been removed. It doesn't fully fix the sh(1) build on 64 bits platforms though, there is still some quad_t issues that need to be fixed. Tested on: i386, sparc64
* Correct a usage of fnctl that could not be right and results in anectar2002-09-111-1/+1
| | | | no-op. I assume it was meant that the close-on-exec flag be set here.
* Don't show the process ID of background jobs that have terminated,tjr2002-08-241-1/+1
| | | | for consistency with ksh.
* Avoid accessing the current job's process table in the child part oftjr2002-08-181-3/+5
| | | | | | forkshell() after it has been freed. This caused mysterious behaviour when anything but the first command in a pipeline tried to access the terminal when the `junk' malloc() option was enabled (which is the default).
* Show job control ID, command text, etc. when foreground processes aretjr2002-08-171-7/+2
| | | | | | suspended. This is a followup to rev. 1.51. MFC after: 1 week
* Set opterr to zero to avoid duplicate warnings from getopt(3) for unknowntjr2002-07-251-0/+1
| | | | options.
* Remove broken and incomplete support for old releases of System V,tjr2002-07-191-61/+0
| | | | don't support system that implement getcwd(3) with a pipe to /bin/pwd.
* Avoid using ints or shorts to store process id's, use pid_t instead.tjr2002-07-181-20/+21
| | | | | | The pgrp member of struct job was declared as a short and could not store every possible process group ID value, the rest of them were benign because pid_t happens to be an int.
* Make the message that is printed when the foreground process is terminatedtjr2002-07-181-2/+23
| | | | by a signal the same as pdksh/bash/sh before rev. 1.34.
* Don't assume the shell's controlling terminal is attached to file descriptortjr2002-07-111-8/+27
| | | | | | | | 2. Instead, open /dev/tty. This problem stopped commands in subshells from being executed correctly if standard error was redirected. PR: 36671 Obtained from: NetBSD (but simplified)
* Remove support for the "old" tty driver by unifdef -UOLD_TTY_DRIVER;tjr2002-07-111-40/+0
| | | | | many other parts of the shell are no longer compatible with this, and it makes jobs.c quite cluttered with #ifdef's.
* When growing the job table, don't relocate the jobmru pointer if it's NULL.tjr2002-07-111-1/+2
|
* Print out commands with NTOFD/NFROMFD redirections that close thetjr2002-07-091-1/+4
| | | | descriptors (">&-" or similar) correctly in the jobs(1) command.
* Consistently use FBSDIDobrien2002-06-301-2/+2
|
* Remove two unused variables.jmallett2002-06-201-2/+0
|
* Display job status correctly when a pipeline is suspended.tjr2002-06-041-6/+8
|
* Describe finished jobs as "Done", not "Exit" (SUSv3)tjr2002-06-041-1/+5
|
* Don't output `state' and `current' fields for processes that aren'ttjr2002-06-041-3/+5
| | | | leaders in -l option to jobs(1).
* Correct minor spacing problem in output of jobs -l for pipelines.tjr2002-06-041-1/+1
|
* Support the remaining job ID formats required by SUSv3:tjr2002-06-011-2/+21
| | | | | | %+ (current job, same as %%), %- (previous job), %?str (job with "str" in its command name).
* Add -s (output PID's only) and -l (show PID's) options to the jobs(1)tjr2002-05-311-13/+67
| | | | builtin. Modify the output format to match what SUSv3 requires.
* #if JOBS around a job control-related statement to allow compilation withtjr2002-05-311-0/+2
| | | | job control disabled.
* Break the code to display status info for one job out from showjobs() intotjr2002-05-311-63/+52
| | | | | showjob(), use it inside dowait() to display status info for consistency, and in a format closer to what the standard requires.
* Move job to front of most recently used job list when bg'd or fg'd.tjr2002-05-311-0/+1
|
* Instead of keeping just the jobid of the most recently bg'd or fg'd job,tjr2002-05-311-9/+84
| | | | | | keep a linked list of the jobs, most recently used first. This is required to support the idea of `previous job', and to allow the jobs fg and bg default to be correct according to POSIX.
* Make the fg and bg commands give the output required by SUSv3.tjr2002-05-191-0/+10
| | | | | fg outputs the name of the command, bg outputs the name of the command and the job id.
* Implement the -C (-o noclobber) option, which prevents existing regulartjr2002-05-191-0/+2
| | | | files from being overwritten by shell redirection.
* o __P has been reovedimp2002-02-021-61/+32
| | | | | | | | | | | | | | | | | | o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. o Change int foo() { ... to int foo(void) { ...
* Fix child's SIGSTOP behaviour in scripts.cracauer2001-02-061-1/+2
| | | | | | | | | | | | | | | | | | When a child is receiving SIGSTOP, eval continues with the next command. While that is correct for the interactive case (Control-Z and you get the prompt back), it is wrong for a shellscript, which just continues with the next command, never again waiting for the stopped child. Noted when childs from cronjobs were stopped, just to make more processes (by wosch). The fix is not to return from a job wait when the wait returned for a stopped child while in non-interactive mode. This bahaviour seems to be what bash2 and ksh implement. I tested for correct behaviour for finnaly killing the child with and without forgrounding it first. When not foregrouding before killing, the shell continues with the script, which is what the other shells do as well. Reviewed by: Silence on -current
* Add `_PATH_DEVZERO'.obrien2000-12-091-6/+7
| | | | Use _PATH_* where where possible.
* Implement the <> redirection operator.brian2000-10-031-0/+2
|
* Fix warnings, some of them serious because sh violated namecracauer2000-04-201-1/+0
| | | | | | | | spaces reserved by the header files it includes. mkinit.c still produces C code with redundant declarations, although they are more harmless since they automatically derived from the right places.
* Include strerror(errno) in error messages after failed system calls.cracauer1999-11-291-3/+5
| | | | Fix a warning.
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Various spelling/formatting changes.kris1999-05-081-2/+2
| | | | Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
* Next approach to make loops in interactive interruptable.cracauer1999-04-211-4/+7
| | | | PR: bin/9173
* If traps are set, they are now executed even when a signal-blockingcracauer1998-09-081-4/+7
| | | | | | | | | | | | foreground child is running. Formerly, traps were exceuted after the next child exit. The enables the user to put a breaking wrapper around a blocking application: (trap 'echo trap ; exit 1' 2; ./pestyblocker; echo -n) The "echo -n" after the child call is needed to prevent sh from optimizing the trap-executing shell away. I'm working on this.
OpenPOWER on IntegriCloud