#
3cddabf0 |
|
03-Jan-2024 |
Fu-Cheng Wang <s111062755@m111.nthu.edu.tw> |
sh(1): Grammar fix in jobs.c Event: Advanced UNIX Programming Course (Fall’23) at NTHU. Pull Request: https://github.com/freebsd/freebsd-src/pull/992
|
#
e043f372 |
|
24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
bin: Automated cleanup of cdefs and other formatting Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
|
#
90aea514 |
|
23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
bin: Remove ancient SCCS tags. Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
|
#
1d386b48 |
|
16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
5a1a07f2 |
|
23-Jan-2022 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Don't add something to a null pointer Pointer arithmetic on a null pointer is undefined behavior. The bug can be reproduced by running bin/sh/tests/builtins/wait6.0 with UBSAN. Reported by: Mark Millard Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D34011
|
#
ab41d7f3 |
|
26-Dec-2020 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Explain duplicate tcsetpgrp() calls This is a comment change only.
|
#
6bc7175f |
|
16-May-2020 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix double INTON with vfork The shell maintains a count of the number of times SIGINT processing has been disabled via INTOFF, so SIGINT processing resumes when all disables have enabled again (INTON). If an error occurs in a vfork() child, the processing of the error enables SIGINT processing again, and the INTON in vforkexecshell() causes the count to become negative. As a result, a later INTOFF may not actually disable SIGINT processing. This might cause memory corruption if a SIGINT arrives at an inopportune time. As of r360452, it causes the shell to abort when it would unsafely allocate or free memory in certain ways. Note that various places such as errors in non-special builtins unconditionally reset the count to 0, so the problem might still not always be visible. PR: 246497 Reported by: jbeich MFC after: 2 weeks
|
#
484160a9 |
|
24-Feb-2019 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Add set -o pipefail The pipefail option allows checking the exit status of all commands in a pipeline more easily, at a limited cost of complexity in sh itself. It works similarly to the option in bash, ksh93 and mksh. Like ksh93 and unlike bash and mksh, the state of the option is saved when a pipeline is started. Therefore, even in the case of commands like A | B & a later change of the option does not change the exit status, the same way (A | B) & works. Since SIGPIPE is not handled specially, more work in the script is required for a proper exit status for pipelines containing commands such as head that may terminate successfully without reading all input. This can be something like ( cmd1 r=$? if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then exit 0 else exit "$r" fi ) | head PR: 224270 Relnotes: yes
|
#
bb324af6 |
|
09-Nov-2018 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Unify EXERROR and EXEXEC The difference between EXERROR and EXEXEC was that EXEXEC passed along exitstatus and EXERROR set exitstatus to 2 in the handling code. By changing the places that raised EXERROR to set exitstatus to 2, the handling of EXERROR and EXEXEC becomes the same.
|
#
b5532964 |
|
27-Oct-2018 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Use exitstatus instead of exerrno to pass EXEXEC status No functional change is intended.
|
#
190bc94a |
|
02-Feb-2018 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Refactor job status printing, preparing for -o pipefail and similar No functional change is intended.
|
#
b0125116 |
|
01-Jan-2018 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Move various structs from jobs.h to jobs.c These implementation details of jobs.c need not be exposed.
|
#
c8a5f665 |
|
26-Dec-2017 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Don't leak wait* implementation details from jobs.c
|
#
fbbd9655 |
|
28-Feb-2017 |
Warner Losh <imp@FreeBSD.org> |
Renumber copyright clause 4 Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96
|
#
90a2c7ea |
|
02-Mar-2016 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Don't trust that signal descriptions fit within 49 bytes.
|
#
cad3cc13 |
|
25-Apr-2015 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Pass along SIGINT from a child if job control is enabled, even when not interactive. I added the interactive check in r208881 to be safe, but in actual use (scripts in set -m mode) passing along SIGINT seems best. Discussed with: bdrewery
|
#
22afca9b |
|
01-Mar-2015 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix more compiler warnings.
|
#
edebe564 |
|
31-Jan-2015 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Abort a wait builtin on any trapped signal. This is required by POSIX. PR: 197210 Reported by: ache MFC after: 2 weeks
|
#
622fdf32 |
|
15-Oct-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Remove more gotos.
|
#
33c5acf0 |
|
05-Oct-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Eliminate some gotos.
|
#
cd60e2c6 |
|
04-Sep-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Allow enabling job control without a tty in non-interactive mode. If no tty is available, 'set -m' is still useful to put jobs in their own process groups.
|
#
e61ae4ff |
|
19-Jul-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Remove prefix() function. Use strncmp() instead.
|
#
728e552f |
|
20-Mar-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Don't overwrite old exit status if a PID is reused. Only store exit status for a process if that process has not terminated yet. Test (slow): exit 7 & p1=$!; until exit 8 & p2=$!; [ "$p1" = "$p2" ]; do wait "$p2"; done; sleep 0.1; wait %1; echo $? should write "7".
|
#
76961687 |
|
15-Mar-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Allow kill %job on jobs started without job control. When killing a %job started without job control, kill all processes in it. As with process groups and zombies, if any process in the job can be killed or has already terminated, the command is successful. This also fixes occasional failures of the builtins/kill1.0 test.
|
#
61346cbd |
|
14-Mar-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Add some consts.
|
#
4646e82d |
|
08-Mar-2014 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Successfully do nothing when killing a terminated job. If a job has terminated but is still known, silently do nothing when using the kill builtin with the job specifier. Formerly, the shell called kill() with the process group ID that might have been reused.
|
#
bab29822 |
|
17-Oct-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Remove one syscall when waiting for a foreground job. The getpgrp() call is unnecessary: if there is no job control then the result was not used at all and if there is job control then we are not a subshell and our process group ID is equal to our process ID (rootpid).
|
#
b823fb59 |
|
02-Sep-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix race condition with signals and wait or set -T. The change in r238888 was incomplete. It was still possible for a trapped signal to arrive before the shell went to sleep (sigsuspend()) because a check was missing or because the signal arrived before in_waitcmd was set. On SMP, this bug sometimes caused the builtins/wait4.0 test to take 1 second to execute; it then might or might not fail. On UP, the test almost always failed.
|
#
7cb5a0d8 |
|
24-Aug-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Do not prematurely discard stopped jobs in a wait builtin. If a job is specified to 'wait', wait for it to complete. Formerly, in interactive mode, the job was deleted if it stopped. If no jobs are specified in interactive mode, 'wait' still waits for all jobs to complete or stop. In non-interactive mode, WUNTRACED is not passed to wait3() so stopped jobs are not detected. PR: bin/181435
|
#
f0ef49bb |
|
16-Aug-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Recognize "--" as end of options in bg/fg/jobid builtins.
|
#
0bdd3871 |
|
25-Jul-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Remove #define MKINIT. MKINIT only served for the removed mkinit. Many variables can be static now.
|
#
79b1d318 |
|
05-Jun-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Return status 127 for unknown jobs in wait builtin. This is required by POSIX, at least for pids that are not known child processes. Other problems with job specifications still cause wait to abort with exit status 2. PR: 176916
|
#
a4099656 |
|
05-Jun-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Allow multiple operands in wait builtin. This is only part of the PR; the behaviour for unknown/invalid pids/jobs remains unchanged (aborts the builtin with status 2). PR: 176916 Submitted by: Vadim Goncharov
|
#
5aa6dfda |
|
05-May-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Use O_CLOEXEC and F_DUPFD_CLOEXEC instead of separate fcntl() call.
|
#
58c73bab |
|
27-Apr-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Don't consider jobs -s/-p as reporting the status of jobs. This ensures that something like j=$(jobs -p) does not prevent any status from being written to the terminal.
|
#
46c6b52d |
|
01-Apr-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix various compiler warnings. It now passes WARNS=7 with clang on i386. GCC 4.2.1 does not understand setjmp() properly so will always trigger -Wuninitialized. I will not add the volatile keywords to suppress this.
|
#
d70ad6f2 |
|
15-Mar-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Recognize "--" and explicitly reject options in wait builtin. If syntactically invalid job identifiers are to be taken as jobs that exited with status 127, this should not apply to options, so that we can add options later if need be.
|
#
25e0f0f5 |
|
23-Feb-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig.
|
#
5be97e72 |
|
07-Feb-2013 |
Xin LI <delphij@FreeBSD.org> |
Catch TRACE parameters up with r238888. This change is only needed when debugging is enabled.
|
#
f9b7cc52 |
|
31-Jan-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Show negated commands (!) in jobs output.
|
#
cdbd40cb |
|
25-Dec-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Prefer strsignal() to accessing sys_siglist directly. Accessing sys_siglist directly requires rtld to copy it from libc to the sh executable's BSS. Also, strsignal() will put in the signal number for unknown signals (FreeBSD-specific) so we need not do that ourselves. Unfortunately, there is no function for sys_signame.
|
#
7cbda738 |
|
15-Sep-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Prefer internal nextopt() to libc getopt(). This reduces code duplication and code size. /usr/bin/printf is not affected. Side effect: different error messages when certain builtins are passed invalid options.
|
#
1794251a |
|
29-Jul-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix EINTR race condition in "wait" and "set -T" using sigsuspend(). When waiting for child processes using "wait" or if "set -T" is in effect, a signal interrupts the wait. Make sure there is no window where the signal handler may be invoked (setting a flag) just before going to sleep. There is a similar race condition in the shell language, but scripts can avoid it by exiting from the trap handler or enforcing synchronization using a fifo. If SIGCHLD is not trapped, a signal handler must be installed for it. Only install this handler for the duration of the wait to avoid triggering unexpected [EINTR] errors elsewhere. Note that for some reason only SIGINT and SIGQUIT interrupt a "wait" command. This remains the case.
|
#
fb05913c |
|
28-Jul-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Do not ask for stopped/continued processes if we do not need them rather than retrying wait3 if they happen.
|
#
61fb716a |
|
28-Jul-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Inline waitproc() into its only caller.
|
#
faa787d3 |
|
28-Jul-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Track continued jobs (even if not continued by bg or fg). This uses wait3's WCONTINUED flag. There is no message for this. The change is visible in "jobs" or if the job stops again.
|
#
184dcee2 |
|
15-Jul-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Remove unused variable in_dowait.
|
#
b95fca47 |
|
02-Apr-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix build with -DDEBUG=2. Reported by: Kristof Provost MFC after: 1 week
|
#
caf29fab |
|
04-Feb-2012 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Use vfork in a few common cases. This uses vfork() for simple commands and command substitutions containing a single simple command, invoking an external program under certain conditions (no redirections or variable assignments, non-interactive shell, no job control). These restrictions limit the amount of code executed in a vforked child. There is a large speedup (for example 35%) in microbenchmarks. The difference in buildkernel is smaller (for example 0.5%) but still statistically significant. See http://lists.freebsd.org/pipermail/freebsd-hackers/2012-January/037581.html for some numbers. The use of vfork() can be disabled by setting a variable named SH_DISABLE_VFORK.
|
#
2fae4c3d |
|
25-Jan-2012 |
Philippe Charnier <charnier@FreeBSD.org> |
Add prototypes, ANSIfy functions definitions to reduce WARNS=6 output.
|
#
454a02b3 |
|
13-Jun-2011 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix duplicate prototypes for builtins. Have mkbuiltins write the prototypes for the *cmd functions to builtins.h instead of builtins.c and include builtins.h in more .c files instead of duplicating prototypes for *cmd functions in other headers.
|
#
c543e1ae |
|
12-Jun-2011 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Save/restore changed variables in optimized command substitution. In optimized command substitution, save and restore any variables changed by expansions (${var=value} and $((var=assigned))), instead of trying to determine if an expansion may cause such changes. If $! is referenced in optimized command substitution, do not cause jobs to be remembered longer. This fixes $(jobs $!) again, simplifies the man page and shortens the code.
|
#
47a5ab29 |
|
04-Jun-2011 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Reduce more needless differences between error messages.
|
#
3835f47c |
|
04-Feb-2011 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Remove special code for shell scripts without magic number. These are called "shell procedures" in the source. If execve() failed with [ENOEXEC], the shell would reinitialize itself and execute the program as a script. This requires a fair amount of code which is not frequently used (most scripts have a #! magic number). Therefore just execute a new instance of sh (_PATH_BSHELL) to run the script.
|
#
b9f69695 |
|
30-Jan-2011 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Send messages about signals to stderr. This is required by POSIX and seems to make more sense. See also r217557.
|
#
0d5ccb45 |
|
18-Jan-2011 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Fix signal messages being sent to the wrong file sometimes. When a foreground job exits on a signal, a message is printed to stdout about this. The buffer was not flushed after this which could result in the message being written to the wrong file if the next command was a builtin and had stdout redirected. Example: sh -c 'kill -9 $$'; : > foo; echo FOO:; cat foo Reported by: gcooper MFC after: 1 week
|
#
0a62a9ca |
|
21-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Add kill builtin. This allows specifying a %job (which is equivalent to the corresponding process group). Additionally, it improves reliability of kill from sh in high-load situations and ensures "kill" finds the correct utility regardless of PATH, as required by POSIX (unless the undocumented %builtin mechanism is used). Side effect: fatal errors (any error other than kill(2) failure) now return exit status 2 instead of 1. (This is consistent with other sh builtins, but not in NetBSD.) Code size increases about 1K on i386. Obtained from: NetBSD
|
#
b036c75b |
|
12-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Various simplifications to jobs.c: * Prefer kill(-X) to killpg(X). * Remove some dead code. * No additional SIGINT is needed if int_pending() is already true. No functional change is intended.
|
#
c67712a0 |
|
06-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Improve internal-representation-to-text code to avoid binary output. The code to translate the internal representation to text did not know about various additions to the internal representation since the original ash and therefore wrote binary stuff to the terminal. The code is used in the jobs command and similar output. Note that the output is far from complete and mostly serves for recognition purposes.
|
#
fa9e5d05 |
|
05-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: POSIX says there should not be a space between Done and (exitstatus). (On the other hand, (core dumped) does need a space and so does [1] +.)
|
#
1bb49f95 |
|
05-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Improve jobs output of pipelines. If describing the status of a pipeline, write all elements of the pipeline and show the status of the last process (which would also end up in $?). Only write one report per job, not one for every process that exits. To keep some earlier behaviour, if any process started by the shell in a foreground job terminates because of a signal, write a message about the signal (at most one message per job, however). Also, do not write messages about signals in the wait builtin in non-interactive shells. Only true foreground jobs now write such messages (for example, "Terminated").
|
#
ff304d37 |
|
05-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Avoid marking a job as done before it is fully created. In r208489, I added code to reap zombies when forking new processes, to limit the amount of zombies. However, this can lead to marking a job as done or stopped if it consists of multiple processes and the first process ends very quickly. Fix this by only checking for zombies before forking the first process of a job and not marking any jobs without processes as done or stopped.
|
#
5af61b52 |
|
05-Dec-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: jobs -p: Do not ask the kernel for the pgid. The getpgid() call will fail if the first process in the job has already terminated, resulting in output of "-1". The pgid of a job is always the pid of the first process in the job and other code already relies on this.
|
#
a7d5f7eb |
|
19-Oct-2010 |
Jamie Gritton <jamie@FreeBSD.org> |
A new jail(8) with a configuration file, to replace the work currently done by /etc/rc.d/jail.
|
#
9fa5f4a0 |
|
15-Oct-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Use <stddef.h> rather than <sys/stddef.h>. <sys/stddef.h> is only for the kernel and conflicts with <stddef.h>.
|
#
88328642 |
|
13-Oct-2010 |
David E. O'Brien <obrien@FreeBSD.org> |
In the spirit of r90111, depend on c89 and remove the "STATIC" macro and its usage.
|
#
8ab2e970 |
|
13-Oct-2010 |
John Baldwin <jhb@FreeBSD.org> |
Make DEBUG traces 64-bit clean: - Use %t to print ptrdiff_t values. - Cast a ptrdiff_t value explicitly to int for a field width specifier. While here, sort includes. Submitted by: Garrett Cooper
|
#
aa7b6f82 |
|
12-Oct-2010 |
David E. O'Brien <obrien@FreeBSD.org> |
Consistently use "STATIC" for all functions in order to be able to set breakpoints with in a debugger. And use naked "static" for variables. Noticed by: bde
|
#
ed4c3b5f |
|
29-Jun-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Forget about terminated background processes sooner. Unless $! has been referenced for a particular job or $! still contains that job's pid, forget about it after it has terminated. If $! has been referenced, remember the job until the wait builtin has reported its completion (either with the pid as parameter or without parameters). In interactive mode, jobs are forgotten after termination has been reported, which happens before primary prompts and through the jobs builtin. Even then, though, remember a job if $! has been referenced. This is similar to what is suggested by POSIX and should fix most memory leaks (which also tend to cause sh to use more CPU time) with long running scripts that start background jobs. Caveats: * Repeatedly referencing $! without ever doing 'wait', like while :; do foo & echo started foo: $!; sleep 60; done will still use a lot of memory and CPU time in the long run. * The jobs and jobid builtins do not cause a job to be remembered for longer like expanding $! does. PR: bin/55346
|
#
f3d893fc |
|
06-Jun-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Pass through SIGINT from a child if interactive and job control is enabled. This already worked if without job control. In either case, this depends on it that a process that terminates due to SIGINT exits on it (so not with status 1, or worse, 0). Example: sleep 5; echo continued This does not print "continued" any more if sleep is aborted via ctrl+c. MFC after: 1 month
|
#
1f65c541 |
|
24-May-2010 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Reap any zombies before forking for a background command. This prevents accumulating huge amounts of zombies if a script executes many background commands but no external commands or subshells. Note that zombies will not be reaped during long calculations (within the shell process) or read builtins, but those actions do not create more zombies. The terminated background commands will also still be remembered by the shell. PR: bin/55346
|
#
fe0506d7 |
|
09-Mar-2010 |
Marcel Moolenaar <marcel@FreeBSD.org> |
Create the altix project branch. The altix project will add support for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting is a two-module system, consisting of a base compute module and a CPU expansion module. SGI's NUMAFlex architecture can be an excellent platform to test CPU affinity and NUMA-aware features in FreeBSD.
|
#
384aedab |
|
27-Dec-2009 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Various warning fixes (from WARNS=6 NO_WERROR=1): - const - initializations to silence -Wuninitialized (it was safe anyway) - remove nested extern declarations - rename "index" locals to "idx"
|
#
29d401c2 |
|
25-Dec-2009 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Do not run callers' exception handlers in subshells. Reset the exception handler in the child to main's. This avoids inappropriate double cleanups or shell duplication when the exception is caught, such as 'fc' and future 'command eval' and 'command .'.
|
#
c6204d4a |
|
21-Nov-2009 |
Jilles Tjoelker <jilles@FreeBSD.org> |
sh: Some changes to stderr flushing: * increase buffer size from 100 to 256 bytes * remove implied flush from out2str(), in particular this avoids unnecessary flushing in the middle of a -x tracing line * rename dprintf() to out2fmt_flush(), make it flush out2 and use this function in various places where flushing is desired after an error message
|
#
d7f03759 |
|
19-Oct-2008 |
Ulf Lilleengen <lulf@FreeBSD.org> |
- Import the HEAD csup code which is the basis for the cvsmode work.
|
#
de37e41c |
|
07-Oct-2006 |
Stefan Farfeleder <stefanf@FreeBSD.org> |
Add the POSIX option -p to the jobs builtin command. It prints the PID of the 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)
|
#
8dcaad55 |
|
04-Feb-2006 |
Jens Schweikhardt <schweikh@FreeBSD.org> |
Remove some white space at EOL.
|
#
19d099fc |
|
14-Dec-2005 |
Maxim Konovalov <maxim@FreeBSD.org> |
o Now when SIG_IGN signal action for SIGCHLD reap zombies 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
|
#
9957cb23 |
|
05-Sep-2005 |
Stefan Farfeleder <stefanf@FreeBSD.org> |
Print pointers with %p rather than casting them to long.
|
#
0c77b3c9 |
|
02-Dec-2004 |
Maxim Konovalov <maxim@FreeBSD.org> |
o Terminate an endless loop sh -T goes into in dowait() around waitproc(). 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
|
#
6195fb41 |
|
06-Apr-2004 |
Mark Murray <markm@FreeBSD.org> |
Remove clause 3 from the UCB licenses. OK'ed by: imp, core
|
#
e637898e |
|
05-Feb-2004 |
Martin Cracauer <cracauer@FreeBSD.org> |
Commit fix sent by Tor Egge <Tor.Egge@cvsup.no.freebsd.org> 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...).
|
#
1b13752a |
|
28-Jan-2004 |
Nate Lawson <njl@FreeBSD.org> |
Use sys_nsig instead of NSIG for the length of the signal arrays. This is important if we add new signals later. From DragonflyBSD: jobs.c:1.4, trap.c:1.3. Obtained from: DragonflyBSD
|
#
2ba1b30b |
|
05-Jul-2003 |
Diomidis Spinellis <dds@FreeBSD.org> |
Changes following CScout analysis: - 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
|
#
5821bf03 |
|
17-Mar-2003 |
Tim J. Robbins <tjr@FreeBSD.org> |
Flush the output buffers before forking a child process to avoid the child process writing data that the parent should have written. PR: 50051 MFC after: 2 weeks
|
#
c57bc2b1 |
|
27-Jan-2003 |
Tim J. Robbins <tjr@FreeBSD.org> |
Ensure that the TTY file descriptor is greater than or equal to 10 so that it doesn't interfere with the user's redirections. PR: 47136 MFC after: 1 week
|
#
6da31df8 |
|
21-Jan-2003 |
Tim J. Robbins <tjr@FreeBSD.org> |
Make this compile with DEBUG defined now that WARNS=0 has been removed from the Makefile: - Print pointers with %p instead of %x. - Include missing headers to get prototypes. Noticed by: benno
|
#
2e3684f8 |
|
13-Dec-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
When job control is disabled, never show the job id when reporting the status of a background process that has terminated because of a signal.
|
#
ec65e997 |
|
01-Oct-2002 |
Maxime Henrion <mux@FreeBSD.org> |
Use the %t format modifier to print differences between 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
|
#
dde97b32 |
|
11-Sep-2002 |
Jacques Vidrine <nectar@FreeBSD.org> |
Correct a usage of fnctl that could not be right and results in a no-op. I assume it was meant that the close-on-exec flag be set here.
|
#
488edd5b |
|
24-Aug-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Don't show the process ID of background jobs that have terminated, for consistency with ksh.
|
#
4f8fa749 |
|
18-Aug-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Avoid accessing the current job's process table in the child part of 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).
|
#
6c56d935 |
|
17-Aug-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Show job control ID, command text, etc. when foreground processes are suspended. This is a followup to rev. 1.51. MFC after: 1 week
|
#
050f7913 |
|
25-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Set opterr to zero to avoid duplicate warnings from getopt(3) for unknown options.
|
#
2628ebdb |
|
19-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Remove broken and incomplete support for old releases of System V, don't support system that implement getcwd(3) with a pipe to /bin/pwd.
|
#
b80be282 |
|
18-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Avoid using ints or shorts to store process id's, use pid_t instead. 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.
|
#
f1ae2c66 |
|
18-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Make the message that is printed when the foreground process is terminated by a signal the same as pdksh/bash/sh before rev. 1.34.
|
#
6c8bbe74 |
|
11-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Don't assume the shell's controlling terminal is attached to file descriptor 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)
|
#
17f08ec1 |
|
11-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Remove support for the "old" tty driver by unifdef -UOLD_TTY_DRIVER; many other parts of the shell are no longer compatible with this, and it makes jobs.c quite cluttered with #ifdef's.
|
#
0d3d4c12 |
|
10-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
When growing the job table, don't relocate the jobmru pointer if it's NULL.
|
#
90735447 |
|
08-Jul-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Print out commands with NTOFD/NFROMFD redirections that close the descriptors (">&-" or similar) correctly in the jobs(1) command.
|
#
2749b141 |
|
29-Jun-2002 |
David E. O'Brien <obrien@FreeBSD.org> |
Consistently use FBSDID
|
#
4e17884f |
|
19-Jun-2002 |
Juli Mallett <jmallett@FreeBSD.org> |
Remove two unused variables.
|
#
5b96a607 |
|
04-Jun-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Display job status correctly when a pipeline is suspended.
|
#
5179c2f2 |
|
04-Jun-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Describe finished jobs as "Done", not "Exit" (SUSv3)
|
#
cb1a4fb4 |
|
04-Jun-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Don't output `state' and `current' fields for processes that aren't leaders in -l option to jobs(1).
|
#
41d09fe0 |
|
04-Jun-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Correct minor spacing problem in output of jobs -l for pipelines.
|
#
f63d6dbf |
|
31-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Support the remaining job ID formats required by SUSv3: %+ (current job, same as %%), %- (previous job), %?str (job with "str" in its command name).
|
#
ad8a0759 |
|
31-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Add -s (output PID's only) and -l (show PID's) options to the jobs(1) builtin. Modify the output format to match what SUSv3 requires.
|
#
bdfc15df |
|
31-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
#if JOBS around a job control-related statement to allow compilation with job control disabled.
|
#
e3f30949 |
|
31-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Break the code to display status info for one job out from showjobs() into showjob(), use it inside dowait() to display status info for consistency, and in a format closer to what the standard requires.
|
#
3771ef59 |
|
30-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Move job to front of most recently used job list when bg'd or fg'd.
|
#
d86825be |
|
30-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Instead of keeping just the jobid of the most recently bg'd or fg'd job, 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.
|
#
addcdbb2 |
|
19-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Make the fg and bg commands give the output required by SUSv3. fg outputs the name of the command, bg outputs the name of the command and the job id.
|
#
1a958c66 |
|
19-May-2002 |
Tim J. Robbins <tjr@FreeBSD.org> |
Implement the -C (-o noclobber) option, which prevents existing regular files from being overwritten by shell redirection.
|
#
5134c3f7 |
|
01-Feb-2002 |
Warner Losh <imp@FreeBSD.org> |
o __P has been reoved 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) { ...
|
#
adce2a1b |
|
06-Feb-2001 |
Martin Cracauer <cracauer@FreeBSD.org> |
Fix child's SIGSTOP behaviour in scripts. 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
|
#
1a37aa56 |
|
09-Dec-2000 |
David E. O'Brien <obrien@FreeBSD.org> |
Add `_PATH_DEVZERO'. Use _PATH_* where where possible.
|
#
4682f420 |
|
03-Oct-2000 |
Brian Somers <brian@FreeBSD.org> |
Implement the <> redirection operator.
|
#
f01e3d0c |
|
20-Apr-2000 |
Martin Cracauer <cracauer@FreeBSD.org> |
Fix warnings, some of them serious because sh violated name 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.
|
#
6c48b6cf |
|
29-Nov-1999 |
Martin Cracauer <cracauer@FreeBSD.org> |
Include strerror(errno) in error messages after failed system calls. Fix a warning.
|
#
2a456239 |
|
27-Aug-1999 |
Peter Wemm <peter@FreeBSD.org> |
$Id$ -> $FreeBSD$
|
#
46be34b9 |
|
08-May-1999 |
Kris Kennaway <kris@FreeBSD.org> |
Various spelling/formatting changes. Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
|
#
57b2932a |
|
21-Apr-1999 |
Martin Cracauer <cracauer@FreeBSD.org> |
Next approach to make loops in interactive interruptable. PR: bin/9173
|
#
135421dd |
|
08-Sep-1998 |
Martin Cracauer <cracauer@FreeBSD.org> |
If traps are set, they are now executed even when a signal-blocking 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.
|
#
1f40b47b |
|
25-Aug-1998 |
Martin Cracauer <cracauer@FreeBSD.org> |
Improve bookkeeping of in_waitcmd and style fixes. Submitted by: Bruce Evans
|
#
7a8e920b |
|
24-Aug-1998 |
Martin Cracauer <cracauer@FreeBSD.org> |
Do not exit on SIGINT in non-interactive shells, fixes PR 1206, i.e. this makes emacs usable from system(3). Programs called from shellscripts are now required to exit with proper signal status. That means, they have to kill themself. Exiting with faked numerical exit code is not sufficient. Exit with proper signal status if script exits on signal. Make the wait builtin interruptable, both with and without traps set. Use volatile sig_atomic_t where (and only where) appropriate. (Almost) fix printing of newlines on SIGINT. Make traps setable from trap handlers. This is needed for shellscripts that catch SIGINT for cleanup work but intend to exit on it, hance have to kill themself from a trap handler. I.e. mkdep. While I'm at it, make it -Wall clean. -Wall is not enabled in Makefile, since vararg warnx() macro calls in usr.bin/printf/printf.c are not -Wall-able. PR: 1206 Obtained from: Basic SIGINT fix from Bruce Evans
|
#
3d7b5b93 |
|
18-May-1998 |
Philippe Charnier <charnier@FreeBSD.org> |
Add rcsid. Spelling.
|
#
8624242a |
|
06-Feb-1998 |
Martin Cracauer <cracauer@FreeBSD.org> |
Back out my previous attempt to fix SIGINT/SIGTERM behaviour
|
#
9dee16db |
|
06-Feb-1998 |
Martin Cracauer <cracauer@FreeBSD.org> |
Fix handling of SIGINT/SIGQUIT for foreground subprocesses. Most urgent need is when you run sh around a program that intentionally uses SIGQUIT/SIGINT for asynchronous events, i.e. $EDITOR started from system(2), like many mailers do. This fixes PR bin/1206 and possibly bin/4241. The solution committed has been tested for a large number of possible cases (see recent discussion on cvs-committers). I completed a make world, made sure 'make world' is interruptable and used the changed /bin/sh as a login shell all day, including job control and using SIGQUIT-catching programs (to write this message :-). PR: bin/1206 Reviewed by: discussion on cvs-commiters
|
#
007d3350 |
|
10-Dec-1997 |
Eivind Eklund <eivind@FreeBSD.org> |
Remove simultaneous include of <sys/param.h> and <sys/types.h>. Reorder includes to be alphabetical some places since I already was in here.
|
#
ead152eb |
|
17-Aug-1997 |
Steve Price <steve@FreeBSD.org> |
Make all status values an integral type and use pid_t when referring to process IDs.
|
#
00fc54b0 |
|
24-May-1997 |
Steve Price <steve@FreeBSD.org> |
Make sh(1) less aware of the bit fields returned by wait by using the WIF* macros in sys/wait.h. PR: bin/3668 Submitted by: dholland@eecs.harvard.edu
|
#
e7a0b024 |
|
18-May-1997 |
Steve Price <steve@FreeBSD.org> |
Use the __unused attribute where warranted.
|
#
afb033d5 |
|
27-Apr-1997 |
Steve Price <steve@FreeBSD.org> |
Nuke register keyword usage and #if -> #ifdef. Obtained from: NetBSD
|
#
b97fa2ef |
|
22-Feb-1997 |
Peter Wemm <peter@FreeBSD.org> |
Revert $FreeBSD$ to $Id$
|
#
1130b656 |
|
14-Jan-1997 |
Jordan K. Hubbard <jkh@FreeBSD.org> |
Make the long-awaited change from $Id$ to $FreeBSD$ This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
|
#
938ddab4 |
|
05-Jan-1997 |
Steve Price <steve@FreeBSD.org> |
Fix a problem that caused some foreground pipelines to die with: tcsetpgrp failed, errno=1 Discovered and Reviewed by: joerg
|
#
ab0a2172 |
|
13-Dec-1996 |
Steve Price <steve@FreeBSD.org> |
Merge in NetBSD mods and -Wall cleaning. Obtained from: NetBSD, me
|
#
856541b9 |
|
15-Oct-1996 |
Steve Price <steve@FreeBSD.org> |
Benign | --> || correction.
|
#
4417f629 |
|
03-Sep-1996 |
Peter Wemm <peter@FreeBSD.org> |
Fix for PR#1287. This makes sh behave sensibly in case statements in the face of aliases. Note, bash doesn't do aliases while running scripts, but "real" ksh does.. Also: Reduce redundant .Nm macros in (unused) bltin/echo.1 nuke error2, it's hardly used. More -Wall cleanups dont do certain history operations if NO_HISTORY defined handle quad_t's from resource limits Submitted by: Steve Price <sprice@hiwaay.net> (minor tweaks by me)
|
#
16992ff4 |
|
03-Sep-1996 |
Peter Wemm <peter@FreeBSD.org> |
Misc cleanups and fixes from Bruce: - don't put \n on error() calls, error adds it already. - don't prepend "ulimit" on error() calls in miscbltin.c. - getopt typo on ulimit -p -> -u conversion - get/setrlimit() calls were not being error checked ulimit formatting cleanup from me, use same wording as bash on Bruce's suggestion. Add ulimit arg to output on Joerg's suggestion.
|
#
aa9caaf6 |
|
01-Sep-1996 |
Peter Wemm <peter@FreeBSD.org> |
Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is a merge of parallel duplicate work by Steve Price and myself. :-] There are some changes to the build that are my fault... mkinit.c was trying (poorly) to duplicate some of the work that make(1) is designed to do. The Makefile hackery is my fault too, the depend list was incomplete because of some explicit OBJS+= entries, so mkdep wasn't picking up their source file #includes. This closes a pile of /bin/sh PR's, but not all of them.. Submitted by: Steve Price <steve@bonsai.hiwaay.net>, peter
|
#
069428af |
|
26-May-1996 |
Peter Wemm <peter@FreeBSD.org> |
Import the 4.4BSD-Lite2 /bin/sh sources Requested by: joerg (Note, this is mostly going to be conflicts, which is expected. Our entire sh source has a mainline, so this should not change anything except for a few new files appearing. I dont think they are a problem)
|
#
beff5288 |
|
21-Sep-1995 |
Bruce Evans <bde@FreeBSD.org> |
Fix relocation of job table. while { sleep 1 & wait; } do echo 1; done corrupted the job table every 4th iteration.
|
#
2162b2d2 |
|
29-May-1995 |
Rodney W. Grimes <rgrimes@FreeBSD.org> |
Remove trailing whitespace. Reviewed by: phk
|
#
89730b29 |
|
23-Sep-1994 |
David Greenman <dg@FreeBSD.org> |
Added $Id$
|
#
4b88c807 |
|
26-May-1994 |
Rodney W. Grimes <rgrimes@FreeBSD.org> |
BSD 4.4 Lite bin Sources
|