Skip to content

fix(jobs): resolve portability issues with background job cleanup#61830

Open
stklcode wants to merge 2 commits into
nextcloud:masterfrom
stklcode:fix/61635-ps
Open

fix(jobs): resolve portability issues with background job cleanup#61830
stklcode wants to merge 2 commits into
nextcloud:masterfrom
stklcode:fix/61635-ps

Conversation

@stklcode

@stklcode stklcode commented Jul 5, 2026

Copy link
Copy Markdown

Summary

This PR resolves two issues with background job cleanup introduced recently:

Portability of cleanup on Alpine, BSD and macOS

The previous implementation executes "ps" with flags -p and -o to check whether a job process was still running. This approach has portability issues regarding e.g.

  • BusyBox ps (Alpine Linux) where ps -p fails
ps: unrecognized option: p
BusyBox v1.37.0 (2026-01-10 15:38:28 UTC) multi-call binary.

Usage: ps [-o COL1,COL2=HEADER] [-T]

Show list of processes

	-o COL1,COL2=HEADER	Select columns for display
	-T			Show threads

(this affects the official "fpm-alpine" Docker image)

  • BSD/macOS where ps -o fails
ps: cmd: keyword not found
ps: no valid keywords; valid keywords:

Replace with posix_kill($pid, 0), the standard POSIX way to probe process existence without delivering a signal. EPERM is treated as "process exists but not owned by current user". This should be available on all supported platforms.

Hardcoded snowflake ID prevents background_jobs_expiration_days

Snowflake ID in JobRuns:deleteBefore() is computed from given timestamp, but immediately overwritten by a literal value making the expiration setting have no effect.

This looks like a leftover artifact from development that should be cleaned up. Remove the hardcoded ID to restore the desired behavior.

Both fixes suggested by @mmdevl in the linked issue.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@stklcode stklcode requested a review from a team as a code owner July 5, 2026 08:42
@stklcode stklcode requested review from come-nc, icewind1991, leftybournes and salmart-dev and removed request for a team July 5, 2026 08:42
@SystemKeeper SystemKeeper requested a review from Altahrim July 5, 2026 16:24
@susnux susnux added the community pull requests from community label Jul 6, 2026

@Altahrim Altahrim left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement, thank you!

(and yes… remaining test thank you for catching it!)

@come-nc come-nc added the 3. to review Waiting for reviews label Jul 6, 2026
@come-nc come-nc added this to the Nextcloud 35 milestone Jul 6, 2026
stklcode added 2 commits July 6, 2026 14:42
The previous implementation executes "ps" with flags -p and -o to check
whether a job process was still running. This approach has portability
issues regarding e.g. BusyBox ps (Alpine Linux) where `ps -p` fails or
BSD/macOS where `ps -o` fails.

Replace with `posix_kill($pid, 0)`, the standard POSIX way to probe
process existence without delivering a signal. EPERM is treated as
"process exists but not owned by current user". This should be available
on all supported platforms.

Fixes: 60ce92a
Suggested-by: Michele Marcionelli
Signed-off-by: Stefan Kalscheuer <stefan@stklcode.de>
Snowflake ID in `JobRuns:deleteBefore()` is computed from given
timestamp, but immediately overwritten by a literal value making the
expiration setting have no effect.

This looks like a leftover artifact from development that should be
cleaned up. Remove the hardcoded ID to restore the desired behavior.

Fixes: dc5499a
Suggested-by: Michele Marcionelli
Signed-off-by: Stefan Kalscheuer <stefan@stklcode.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews community pull requests from community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background job cleanup fails on BSD/macOS; also background_jobs_expiration_days is ignored

4 participants