Path: ...!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail From: Christian Weisgerber Newsgroups: comp.unix.shell Subject: Re: (bash) How (really!) does the "current job" get determined? Date: Fri, 4 Oct 2024 22:48:15 -0000 (UTC) Message-ID: References: <20241003170607.397@kylheku.com> <20241004070133.515@kylheku.com> Injection-Date: Fri, 4 Oct 2024 22:48:15 -0000 (UTC) Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1"; logging-data="60034"; mail-complaints-to="usenet@mips.inka.de" User-Agent: slrn/1.0.3 (FreeBSD) Bytes: 2060 Lines: 30 On 2024-10-04, Janis Papanagnou wrote: >>> What? Scripting should not go anywhere near POSIX job control, which is >>> an interactive feature that requires a terminal session. >> >> Well, there _is_ set -m. > > And how will that devaluate what Kaz has said? Please elaborate. Job control does not require an interactive shell or a terminal session. It can be used in scripting. That's the facts. > or if you know of any useful and sensible application contexts > for non-interactive usages I'd certainly be curious to know.[*] I'm curious myself. That said, here's something I stumbled across recently: background job & ... kill %1 # clean up What happens if the background job has already terminated on its own accord before we reach the kill(1)? Not much, because with job control, the shell knows that no such job exists. If you do this with "kill $!", you signal that PID, which no longer refers to the intended process and may in fact have been reused for a different process. -- Christian "naddy" Weisgerber naddy@mips.inka.de