set_times() has one caller: Job_Touch(). set_times() is a thin
utimes(2) wrapper. Using utimes(2) to reset a file's atime/mtime
to the current time is not cumbersome.
So, remove set_times() and just call utimes(2) directly.
Thread: https://marc.info/?l=openbsd-tech&m=171262211713835&w=2
ok kn@
other BSDs, which never happened, so make things simpler for further
development.
Ditches config.h entirely since it gets reduced to 2 defines.
okay tb@
is basically silent.
Record errors due to missing permissions and other oddities, and display them
when we error out due to lack of targets, as a quality-of-life diagnostic.
Based on a remark from sthen@, with some feedback and tweaks from op@
okay op@, kn@
reaper. Specifically, the sigprocmask/wait/sigsuspend dance is correct for
the main process, BUT you have to remember to reset the signal mask to
something sane for the child (this was a duh! moment, that bug is very
stupid)
Finally, bluhm@ saw the actual issue. Kudoes to him.
The change to "unify" sequential and parallel make made the bug reproducible
under some circumstances
(because in the parallel make case, many things may happen in different
successions, so you don't get the wrong signal mask that often, but the
sequential case is reproducible, and using the "streamlined" reaper meant the
fork would occur WITHIN the signal loop instead of OUTSIDE)
So:
- discover signal state early on through Sigset_init;
- introduce reset_signal_mask to get back to the initial state;
- call reset_signal_mask systematically after fork
This organisation thanks to cmd_exec. SOME cmd_exec happens before Job_Init
happens, some afterwards (variables are still lazy and both !!= and :sh will
occur AFTER parsing), so both fork() need to be protected.
okay bluhm@
thx to sthen@ and naddy@ and mpi@ for helping out.
- have a simple variable "sequential" that counts whether we are
running more than one job (for the expensive heuristics)
- don't expose various things globally, just have a set_noparallel() for
the parser
- preallocate exactly enough job structures and record them in availableJobs
- keep one job on the side for .INTERRUPT
- rename context into localvars, which is more meaningful and less generic
- instantiate the random rumbling at the start of gnode.h with actual
variable names
- explain and group gnode.h variables better
- make some comments terser/more meaningful
okay millert@
else, in some cases by adding extra temporary variables.
IMO, it's much better practice to do
void *a;
int *p = a;
*p = 42;
rather than
void *a;
*(int *)a = 42;
okay miod@... to be revisited for some possible const additions later.
fork a shell then (as seen in a commit message in netbsd's make, apparently
taken from debian. didn't look at the actual code, but it was a "duh" moment)
okay millert@
the extra field.
remove some extra abstraction layer: use clock_gettime directly
instead of ts_set_from_now (what is "now" anyways)
time_to_string takes param by pointer
rename "now" into starttime (more accurate term)
randomize queue uses arc4random_uniform (prompted by deraadt@)
display debug timestamp with ns too (it's debug, so it doesn't really
matter whichever way it's done, as long as it's done)
okay millert@
while there, clean up includes.
use strtoll for ar timestamps (pretty much unused in reality, more
standard conforming than anything)
use idea from Todd to adapt to time_t being 32 bits OR 64 bits
(pedantically correct: INT_MIN would work just fine up to 1910 or so...)
okay millert@, gone thru a make build.
of prerequisites. This prevents complaints from the var module and from
other developers.
That's a bug I introduced 5 years ago... found out by miod@
okay miod@
- do ^C checking differently: don't record sent signals, but when jobs
die, recheck whether we received/have pending a INT/QUIT/TERM/HUP signal.
Then don't display our process group "normally", instead group together
everything dying by signal/shell dying by signal (just give the target
names).
- make certain we always handle signals before dying from "other conditions"
- have the parser messages look more like normal messages
- remove double error messages from some parser errors
- make sure unclosed variables ARE errors when some modifiers are present
- keep track of the base directory we're run from, so that submakes can
get shortened directories...
- make sure the whole error message including silent command fits into a
reasonable length.
okay millert@
signal because the process already bought it (pgroups will do that to you)
(lots of discussion with Todd on that one)
- tweak error handling some more to make it less verbose when just one job
is running...
- show signal name in case of signal interrupts.
- zap OP_LIB, move that stuff to the location where we warn when we meet
that bug.
okay millert@
- put back some job control, turns out it's necessary when we don't run a
shell.
- zap old #ifdef CLEANUP code... probably doesn't even compile.
- kill most of the OP_LIB code. Just keep a wee little bit for compatibility
(deprecated .LIBS and .INCLUDES, warns for weird dependencies instead of
erroring out).
- much improved debugging and -p output: sort variables, targets, rules,
output stuff in a nicer format mimicing input.
- better error message when no command is found, explain where the target comes from.
- sort final error list by file.
- show system files in errors as <bsd.prog.mk>
- reincorporate random delay, that was dropped
- optimize siginfo output by not regenerating the whole string each time.
- finish zapping old LocationInfo field that's no longer used.
instead of forking a "job" per target, and having that job further fork
separate commands, have make maintain a list of jobs, indexed by pid
of currently running commands, and handle process termination
continuation-style. This has lots of benefits:
- make is responsible for most printing, so we no longer need pipes nor
job control: make -j jobs see the tty.
- no more special-casing for jobs that don't really execute anything.
- unify code for make -jn and make -B, including signal handlers and
job waiting. So make -n, make -q, +cmd now run commands in the same
way in all cases.
- unified more accurate error-reporting, as make knows precisely which
command failed. Commands are tagged with their lines, and we display failing
commands in silent mode.
- fine-grained "expensive" command handling (recursion limiter). Do it
per-command instead of per-target.
Moreover, signal response is now simpler, as we just block the signals
in a small critical sections, test for events, and sigpause (thanks a lot
to guenther@ and millert@), so running make is now almost always paused
without any busy-waiting.
Thanks to everyone who tested and gave input.
test:
! pgrep process
work, without trying to look for a '!' command
(remember that not running a shell for each command is an optimization ?)
bug fix prompted by eric@'s remark, okay millert@
- add info to be able to pinpoint parse errors at runtime.
- let job runners abort when a parse error happens while expanding a variable
during execution
- fix an infinite loop when compiling without FEATURE_RECVARS.
okay millert@, krw@
the very few errors found out by this (less than 10 over src/X/ports)
fixed trivially beforehand, as requested by deraadt@