Announcement

Collapse
No announcement yet.

Glibc 2.34 Adds "_Fork" Function Ahead Of Future POSIX Revision

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • linuxgeex
    replied
    Originally posted by pal666 View Post
    just like fork from main is flawed because there should be only one main thread?
    how would you attach debugger from a signal handler?
    Generally speaking it's poor form to fork() from a thread, period. There are hacks to try to work around the problems created by forking from a thread (fork creates a process on a COW copy of the stack of the thread, along with the entire parent process memory, including held mutexes.) A signal handler basically uses a broken kernel implementation of threading (anyone who writes C signal handlers rapidly learns the limitations thereof) and has the exact same issues for fork().

    A debugger attaches to a process with the CPU's stepping mode enabled.
    Last edited by linuxgeex; 04 July 2021, 12:25 PM.

    Leave a comment:


  • pal666
    replied
    Originally posted by linuxgeex View Post
    Exactly. fork() in a signal handler is 100% always a bug. Only one thread should be responding to a signal. fork()ing creates a second process with a COW stack of that signal handler. That's plain and simply flawed software architecture.
    just like fork from main is flawed because there should be only one main thread?
    Originally posted by linuxgeex View Post
    There's no prize for last place in software design.
    how would you attach debugger from a signal handler?

    Leave a comment:


  • pal666
    replied
    Originally posted by MaxToTheMax View Post
    More gratuitous underscores all over everything.
    names starting with underscore and capital letter are reserved, anything else could be user-defined macro which will break existing programs
    Originally posted by MaxToTheMax View Post
    I'd rather fork() was just fixed.
    it's "fixed" by not running atfork handlers. i'd rather not let you break fork under the pretense of fixing it

    Leave a comment:


  • uxmkt
    replied
    Originally posted by bregma View Post
    Whatever happened to the async-signal-safe `posix_spawn()` call that already does the right thing and is already in POSIX?
    posix_spawn warrants a posix_spawn_file_actions_t structure. Most code just builds it before posix_spawn, but with regard to the bug report, a program would have to build it before even entering the signal handler - which I guess is doable, but people and programs failed to do so.

    Leave a comment:


  • linuxgeex
    replied
    Originally posted by jabl View Post

    As mentioned, the problem is that even if fork() were to be AS-safe, a programmer might not be aware or able to control what various libraries are doing in their pthread_atfork() handlers. So if they do something AS-unsafe, you're back to square one anyway. So _Fork(), ugly name notwithstanding, is a more robust solution for the problem of how use fork in a signal handler.

    Besides, on Linux one should be using signalfd rather than messing around with signal handlers and worrying about AS-safety anyway.
    Exactly. fork() in a signal handler is 100% always a bug. Only one thread should be responding to a signal. fork()ing creates a second process with a COW stack of that signal handler. That's plain and simply flawed software architecture. There's no prize for last place in software design.

    Leave a comment:


  • milkylainen
    replied
    I would vote for the missed opportunity to go all camelcase unreadable batshit crazy on the function name.
    This half-assed _Fork is very meh.

    __F0rK_n0t_ASYNCSH1tZ!__

    Then we could all vote for rewriting Glibc in Java or something useful when we're already doing unreadable.

    Leave a comment:


  • cmsigler
    replied
    Originally posted by coder View Post
    This represents a major missed opportunity not to call it spoon()!
    SPOON!
    Last edited by cmsigler; 29 June 2021, 10:26 AM.

    Leave a comment:


  • skeevy420
    replied
    Well fork me running.

    Leave a comment:


  • bregma
    replied
    Whatever happened to the async-signal-safe `posix_spawn()` call that already does the right thing and is already in POSIX?

    Leave a comment:


  • jabl
    replied
    Originally posted by uid313 View Post
    Oh so this is one thing where BSD is better than Linux.
    As mentioned, the problem is that even if fork() were to be AS-safe, a programmer might not be aware or able to control what various libraries are doing in their pthread_atfork() handlers. So if they do something AS-unsafe, you're back to square one anyway. So _Fork(), ugly name notwithstanding, is a more robust solution for the problem of how use fork in a signal handler.

    Besides, on Linux one should be using signalfd rather than messing around with signal handlers and worrying about AS-safety anyway.

    Leave a comment:

Working...
X