haskell / haskell/process

Decreasing process priority...

Open
#281 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
91
Forks
91
PR merge metrics
No merged PRs in 30d

Description

The way that process attributes are handled on Posix platforms
is that we call a function just after `fork` and before `exec`.
This allows common actions like:

* [ ] decreasing process CPU priority and IO priority
* [ ] dropping security capabilities
* [ ] closing FDs
* [ ] detaching process group

Most of these use cases are already supported by `CreateProcess` interface,
however decreasing priority, and dropping capabilities is not supported.

I suggest adding new fields to `CreateProcess`:

1. `lowerCPUPriority :: Int` -- lower priority of the child process
2. `ioPriority :: Int` -- lower IO priority (see https://linux.die.net/man/1/ionice)
3. `dropCapabilities :: [Capability]` -- drop process capabilities (see https://hackage.haskell.org/package/linux-capabilities-0.1.1.0/docs/System-Linux-Capabilities.html for a list of capabilities, and https://man7.org/linux/man-pages/man7/capabilities.7.html for explanations)
4. `changeNamespace :: NamespaceChange` (see https://en.wikipedia.org/wiki/Linux_namespaces)
With additional datatype:
```
data NamespaceChange = SameNamespace
| CloneNamespace [Unshare]
| EnterNamespace FD

```

Use cases for 1 and 2 are particularly common when managing batch jobs from user interface.
Facilitation would help all interactive applications, in particular language server.

Facilitating 3 and 4 would encourage using Haskell for high-security applications, since both capabilties and namespaces are used for secure containers.

I am willing to provide MR, if maintainers accept.
The numbers above indicate both simplicity and frequency with which new features are likely to be used.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the CreateProcess interface and the Posix process-attribute handling described in the issue; no file or test is named. Done would require an agreed scope for the requested priority and process-attribute changes, with validation identified by the maintainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, linux
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.