OS/X Fork Broken



  • Just found this from a post on the Samba-technical mailing list. Apparently one of the reasons that Apple switched off of Samba to use their own SMB server is that Samba really doesn't work well with their borked fork(). As I understand it, you basically have to exec() right after your fork(). Check out the caveats on the OS/X fork():

    [snip]
    CAVEATS
    There are limits to what you can do in the child process. To be totally safe you should restrict yourself to only executing async-signal safe operations until such time as one of the exec functions is called. All APIs, including global data symbols, in any framework or library should be assumed to be unsafe after a fork() unless explicitly documented to be safe or async-signal safe. If you need to use these frameworks in the child process, you must exec. In this situation it is reasonable to exec yourself.
    []snip]


    Makes me wonder how this is POSIX compliant. Then again, NT has a messed up fork() and it's technically POSIX compliant.


  • This makes perfect sense to me. For example, whenever I want to split a sandwich with someone, I cut the sandwich in half, and then throw away the halves and make two new sandwiches. I mean, you never know when there might be some quantum entanglement between the two halves. Then they wouldn't be fully separated!



  • @Gazzonyx said:

    As I understand it, you basically have to exec() right after your fork().
    This caveat isn't limited to OS/X.



  • @curtmack said:

    This makes perfect sense to me. For example, whenever I want to split a sandwich with someone, I cut the sandwich in half, and then throw away the halves and make two new sandwiches. I mean, you never know when there might be some quantum entanglement between the two halves. Then they wouldn't be fully separated!

     

    I just use a fork to stab the other person until they stop wanting a sandwich / breathing, and then I eat their sandwich.

    On a side note, does anyone know a good replacement for Panera Breads? For some reason, I'm banned from the chain. 😞

     



  • @Lorne Kates said:

    On a side note, does anyone know a good replacement for Panera Breads? For some reason, I'm banned from the chain. 😞

     

    How do you get banned from a whole chain? A sandwich shop chain!



  • @PJH said:

    @Gazzonyx said:
    As I understand it, you basically have to exec() right after your fork().
    This caveat isn't limited to OS/X.

     

    Actually, this behaviour is vfork(). And even BSD said depending on this behaviour is deprecated. Linux brought it back -- it makes for some efficiencies over fork() if an exec() follows.

    But, it is borked fork() behaviour. And stupid.

     



  • @Lorne Kates said:

    On a side note, does anyone know a good replacement for Panera Breads? For some reason, I'm banned from the chain. 😞

    Almost anywhere is better than Panera (the dumpster behind the Panera is the only exception that comes to mind). But I, too, want to know how to get myself banned from them all, because what a great excuse when discussing where to go for lunch!



  • @lurch said:

    Actually, this behaviour is vfork(). And even BSD said depending on this behaviour is deprecated. Linux brought it back -- it makes for some efficiencies over fork() if an exec() follows.

    But, it is borked fork() behaviour. And stupid.

    Hmm....from my vfork man page:
    @man vfork said:

    Historic Description

       Under Linux, fork(2) is implemented using copy-on-write pages, so the only penalty incurred by fork(2) is the time and memory required to duplicate the parent's page tables, and to cre‐
       ate a unique task structure for the child.  However, in the bad old days a fork(2) would require making a complete copy of the caller's data space, often needlessly, since usually imme‐
       diately afterward an exec(3) is done.  Thus, for greater efficiency, BSD introduced the vfork() system call, which did not fully copy the address space of the parent process,  but  bor‐
       rowed  the  parent's  memory  and thread of control until a call to execve(2) or an exit occurred.  The parent process was suspended while the child was using its resources.  The use of
       vfork() was tricky: for example, not modifying data in the parent process depended on knowing which variables were held in a register.</blockquote>


  • @rudraigh said:

    @Lorne Kates said:

    On a side note, does anyone know a good replacement for Panera Breads? For some reason, I'm banned from the chain. 😞

     

    How do you get banned from a whole chain? A sandwich shop chain!

     

    I don't know. The manager wouldn't tell me, just kept screaming about arteries or something. Typical corporate lack of customer service and communication.

     

     



  • @rudraigh said:

    How do you get banned from a whole chain? A sandwich shop chain!
     

    Two guys in UK getting banned from a "all you can eat" resturant for eating too much...

    Having said that, there's numerous ISPs that have throttled unmetered accounts for consuming too much bandwidth.



  • @Lorne Kates said:

    I don't know. The manager wouldn't tell me, just kept screaming about arteries or something.
     

    Report it here, verbatim.

    Goooo onnnnnnn.....



  • @Cassidy said:

    Report it here, verbatim.

     

    [url="http://notalwaysworking.com/instantly-in-trouble/26702"]First article[/url] from a manager whose coffee machine broke. Employee (ostensibly TWTF of the article) sells coffee instant:


     Me (manager): “Do you mean you’ve just been putting ground coffee in a cup then adding boiling water from the kettle?”

    Employee: “Well, duh, that’s how you make instant coffee!”

    Me: “HOW MANY PEOPLE HAVE YOU SOLD COFFEE TO IN THE LAST FEW MINUTES?!”

    WTF? Has the article submitter never heard of french press coffee. Did he think the coffee machine somehow magically interacted with the coffee grounds in a way other than dumping boiling water ontop of the grounds. Given, the customer would have to contend with the grounds, and the portions would need to be tweaked-- but rather than going ballistic apeshit, he should have thanked the employee for the initiative, and realized that he didn't have to lose an entire day of coffee sales. Hell, if he put up "hand brewed, traditionally filtered", he probably could have charged double.

    So thank you for showing me that this website isn't the only place I can say "OP is TRWTF".

     



  • @Gazzonyx said:

    OS/X

    Since when did IBM buy Apple?



  • @Lorne Kates said:

    Given, the customer would have to contend with the grounds, and the portions would need to be tweaked
     

    That was probably the issue the submitter was trying to convey - facing angry customers with inedible coffee dust spilling down their chins.

    Granted (given how cafetieres work) the process followed by the kid isn't exactly alien, OP is unnecessarily flying off the handle on that one.



  • @Gazzonyx said:

    Then again, NT has a messed up fork() and it's technically POSIX compliant.
    I thought it wasn’t “messed up” so much as “slow and expensive as fuck.” At least, that’s what some quick googling leads me to believe. It works otherwise correctly, it’s just not really the correct way to do it on Windows, because of the expenses incurred on starting a new process.



  • @curtmack said:

    This makes perfect sense to me. For example, whenever I want to split a sandwich with someone, I cut the sandwich in half, and then throw away the halves and make two new sandwiches. I mean, you never know when there might be some quantum entanglement between the two halves. Then they wouldn't be fully separated!
    There's a much more elegant solution to that. (From my son's favourite cartoon show.)

     

     



  • So... wait, the Talking Tom iPhone app got turned into a cartoon series? What the fuck.



  •  It runs on Android, too.

    And, of course, there are the soft toys.



  • @MiffTheFox said:

    @Gazzonyx said:
    OS/X

    Since when did IBM buy Apple?

    Yeah. No idea why I put that slash in the name.


  • @MiffTheFox said:

    @Gazzonyx said:
    OS/X

    Since when did IBM buy Apple?

    I assumed it was because Macs were bad enough to be considered a competitor to Lotus Notes OS


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.