4 ms·
What I hate about fork is that it fundamentally doesn't even make sense. You fork a process with a window, what happens to that window? Does it get duplicated?
by dataflow 6y ago
What I hate about fork is that it fundamentally doesn't even make sense. You fork a process with a window, what happens to that window? Does it get duplicated? Do both control the same window? It has no sensible behavior in the general case without cloning the whole machine, and even then, your network isn't going to get forked. There are limited cases where it could make sense, but the fact that that's not true in general should make it fairly obvious that we need a different spawning primitive. It boggles my mind that people teach fork as if it could be the primitive.
- megous 6y agoDepends on what do you mean by window. If the window lives in a X server and you clone the client, window will obviously not get duplicated. It's quite clearly defined what gets duplicated and what gets shared on clone()/fork(). There really is no ambiguity.
- Joker_vD 6y agoSo, do threads get duplicated or shared? Or something altogether different happens to them?
- megous 6y agoThat's documented in man 2 fork.
- dataflow 6y agoI'm not saying a particular implementation is ambiguous as to what it does. Obviously any implementation will do something. I'm saying that fork as a concept is ambiguous as to what it should do.
- megous 6y agoYou're forking a process, not the whole system. Sorry, but I fail to see the ambiguity. If the window is in the process as some framebuffer, it gets cloned too. That may not mean you'll get two windows on your monitor, because your display engine is HW thing, and not a process.
- dataflow 6y agoIt's because you're thinking "it does X! it's not ambiguous!" but still missing that the question is over why it SHOULD do X instead of Y, not over whether it does X or Y. To a user, it sure as heck doesn't make sense to fork a process and still end up with one window for both of them. For lots of processes the process is its windows as far as the user is concerned.
- deleted 6y ago[deleted]
- robotresearcher 6y agoFork isn't an idea that users need to have. Devs may need to know what their OS API's fork() does. No-one else cares.
- dataflow 6y agoThat's an argument for "I don't care about this", not an argument for "this abstraction is sensible".
- megous 6y agoUsers don't fork processes, it's a low-level system thing.
- dataflow 6y agoWhy repeat the same thing as the sibling comment posted an hour ago...?
- CRConrad 5y agoUsually because you've had the browser open for a while and are seeing the state after the parent, but before the sibling comment was posted. At least that's usually why it happens for me; refreshing to see if someone else already has said what you want to say is rarely uppermost in my mind when a reply comes to mind. Another possibility (pretty clearly not the case here) is when there are lots of replies: either you just miss it among the others, or ypu just can't be bothered to scroll down half a mile.
- robotresearcher 6y agoPOSIX defines what a POSIX compliant fork() must do.
- dataflow 6y agoYes it does.