Live data from Hacker News

Moving beyond fork() + exec()

lwn.net

321–330 of 358 posts

Re: Moving beyond fork() + exec()

#321
post #319

Earlier quoted context omitted.

It's an elegant hack, but it's still a hack. Not what we should be doing in 2026.

I would prefer to continue to use elegant interfaces even beyond 2026.

I would prefer to use elegant interfaces that aren't massive hacks.

Re: Moving beyond fork() + exec()

#322
post #305

Earlier quoted context omitted.

The value is not needing to change every other syscall and not needing to write new ones with a pid argument (besides which, what when you want to change it to a pidfd argument? then you add pidfd_syscall instead of duplicating every syscall again)

I meant the value of running syscalls in another process from the parent process in contrast to (v)forking and running them in the child directly.

The value is starting the child with a clean slate instead of a copy of its parent.

Re: Moving beyond fork() + exec()

#323

Earlier quoted context omitted.

> being able to inexpensively spawn a carefully tailored process regardless of the size and scope of the current process would be better. It's called clone(2)

Which argument to clone starts the process with an empty address space?

That happens with execve(). clone() allows you to not copy the page table prior to the execve() call.

Re: Moving beyond fork() + exec()

#326
post #66
post #52

Earlier quoted context omitted.

It’s a hack with many disadvantages. Sometimes a hack is the right answer, but the kernel should it add a primitive for it.

Should bash link in every program the user might want? Load them up as dynamic libraries?

Bash as an interactive tool is very different. It is used to run an almost arbitrary number of things, and a pretty low rate.

Bash as a programming language is just a bad idea.

Re: Moving beyond fork() + exec()

#327
post #30

Earlier quoted context omitted.

Spawning processes should not be on the hot path of any program.

It ends up on the hot path of programs that use process isolation aggressively

Sure, and there a primary thing you want is a whole new environment/context for the child (new environment, fds, memory, cgroups, namespaces, etc).

Re: Moving beyond fork() + exec()

#328
post #224

Earlier quoted context omitted.

Fork is conceptually simple. Without bringing in any other layers, you start a process with the one thing known to exist: yourself. Otherwise you need multiple steps to create a process, fill it with something to run, and arrange for it to execute. Or like Win32 you permanently smush them together with other layers, like filesystems and object loaders and linkers.

It's not conceptually simple. No other object creation API works by copying an existing thing and then modifying it. You don't create a new file by copying an existing one and then modifying it. You don't create a new window by copying an existing one and modifying it. Attempting to justify clone/exec as a reasonable design is just Stockholm syndrome.

> No other object creation API works by copying an existing thing and then modifying it.

Clone-and-modify is pretty common in CAD.

> You don't create a new file by copying an existing one and then modifying it.

Clone-and-modify is almost universal in version control systems.

Re: Moving beyond fork() + exec()

#329
post #328

Earlier quoted context omitted.

It's not conceptually simple. No other object creation API works by copying an existing thing and then modifying it. You don't create a new file by copying an existing one and then modifying it. You don't create a new window by copying an existing one and modifying it. Attempting to justify clone/exec as a reasonable design is just Stockholm syndrome.

> No other object creation API works by copying an existing thing and then modifying it. Clone-and-modify is pretty common in CAD. > You don't create a new file by copying an existing one and then modifying it. Clone-and-modify is almost universal in version control systems.

> Clone-and-modify is almost universal in version control systems.

It's closer to copy-on-write. Also, it actually makes sense there because in 99.999% of cases a commit actually is a modified copy of its parent. That isn't true for process spawning.

Re: Moving beyond fork() + exec()

#330
post #324

Earlier quoted context omitted.

I would prefer to use elegant interfaces that aren't massive hacks .

Define "hack".

Something that works but is a surprising and suboptimal way to do things.

I dunno, that's the best I can do for now. Maybe you can do better?

Post reply on HN