install/all.sh captures background PIDs via $(parallel_run_best_effort …), so wait fails and jobs run serially

Aperta Adatta ai principianti
#21 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bash, shell
Ambito
tooling

Direzione di ricerca

Inizia dal commento di intestazione in src/scripts/lib/parallel.sh, poi esamina parallel_run_best_effort e parallel_wait_pids_best_effort. In src/scripts/install/all.sh, gli array REPO_PIDS, ASYNC_PIDS e RPM_PIDS (intorno alle righe 80, 128 e 136) catturano l'output tramite $(...); modifica ciascuno per richiamare direttamente l'helper e aggiungere "$!". Il lavoro è completato quando le chiamate wait smettono di registrare falsi errori e i passaggi di installazione si sovrappongono in un'esecuzione completa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

src/scripts/install/all.sh starts background jobs through command substitution, for example PIDS+=("$(parallel_run_best_effort "$DIR/$script")"). The comment at the top of src/scripts/lib/parallel.sh warns against this pattern:

Capture PIDs in the caller shell (parallel_run_*; PIDS+=($!)), not via $(...), or wait(1) will fail because the background job was started in a subshell.

Severity: medium. This doesn't affect security, but installs run slower than intended and print misleading warnings.

Affected code

src/scripts/install/all.sh: line 80 (REPO_PIDS), line 128 (ASYNC_PIDS), line 136 (RPM_PIDS)

Found while working on #20 (bats unit tests).

What goes wrong

parallel_run_best_effort runs bash "$script" || true & and then echo $!. Because it's called inside $( … ):

  1. The parent shell doesn't own the PID. The job is a child of the command-substitution subshell, so wait <pid> in parallel_wait_pids_best_effort fails, and each wait logs a "WARNING … failed" line even when the script succeeded. Real failures can't be told apart from these false ones.
  2. The jobs run one at a time. The background job inherits the substitution's stdout pipe, so $( … ) blocks until the job finishes and closes that pipe. Each "parallel" step waits for the previous one to finish.

Remediation

Call the helper directly and capture $! in the caller shell, the way ubuntu-setup-scripts and arch-setup-scripts already do:

parallel_run_best_effort "$DIR/$script"
REPO_PIDS+=("$!")

Apply this to every array listed above. Optionally, drop the echo $! from parallel_run_best_effort (or send it to /dev/null) so callers don't depend on stdout. Then run a full install and check that the steps overlap and the "failed" warnings are gone.

Lingua principale
Shell
Stelle
1
Fork
0
Merge medio
1h 7m
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di garretpatten/fedora-setup-scripts

Tutte le issue di garretpatten/fedora-setup-scripts

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.