user_task_count#

Run commands and agent-written programs inside an operating-system boundary. See the guide.

zett_agent.sandbox.resources.user_task_count()[source]#

Return how many processes (and, on Linux, threads) this user owns right now.

RLIMIT_NPROC is compared with this number, not with the size of one process tree: a fork fails once the user owns that many in total. Linux counts threads too (it is “more precisely” a limit on threads), and macOS counts processes only. ps is asked rather than /proc so one code path serves both. None means it could not be counted, and the caller then does not pretend to limit processes.

Return type:

int | None