Re: using select() without blocking the runloop
On Nov 24, 2017, at 1:36 AM, Roland King <rols@...> wrote:
Neither of these statements is correct:
(1) File handles are per-process, not per-thread. It’s the developer’s responsibility not to try to manipulate the same file handle from multiple threads at the same time. They’re shared across a fork() and can be shared across a posix_spawn(), which is how stdin/stdout/stderr is set up in a child process by its parent, but in general this isn’t something an application developer has to worry about. (NSTask deals with all of the gory details of ensuring all of your descriptors don’t get shared to any spawned tasks, only the stdin/stdout/stderr you set.)
(2) Dispatch queue threads are not run in a different process than they’re used from. This doesn’t even really make sense, since if they were in different processes they wouldn’t be sharing memory without using some explicit shared-memory API, and “__block” doesn’t do that.