-
This is trivial in bash with the Something like If this isn't possible, then how should I start a background process then kill it later without resorting to Python's |
Beta Was this translation helpful? Give feedback.
Answered by
ading2210
Mar 24, 2024
Replies: 1 comment
-
I've found a workaround for this using the import xonsh
def get_last_job():
jobs = list(xonsh.jobs.get_jobs().values())
if not jobs:
return None
last_job = max(jobs, key=lambda x: x["started"])
return last_job
sleep 10 &
j = get_last_job()
kill @(j["pids"][0])
kill @(j["pids"][0]) #no such process |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
anki-code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've found a workaround for this using the
xonsh.jobs
module: