[9fans] APE exit() - Plan9

This is a discussion on [9fans] APE exit() - Plan9 ; I have had qualified success porting the latest release of the OpenLDAP client tools to APE. I will raise some of the issues I encountered in a separate discussion, but I had one really bothersome problem and I wonder if ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: [9fans] APE exit()

  1. [9fans] APE exit()

    I have had qualified success porting the latest release of the
    OpenLDAP client tools to APE. I will raise some of the issues I
    encountered in a separate discussion, but I had one really bothersome
    problem and I wonder if there is a trivial fix for something I fail to
    understand.

    It seems that exit() performs a kill() that causes the window in
    which, in this case, ldapsearch runs to close. Using _EXITS(0)
    instead, naturally, has the desired effect, but there has to be a more
    appropriate fix. Any suggestions?

    ++L

    PS: I'm trying very hard to consolidate all the various adjustments I
    have made to APE and the release software into a single offering.
    Sadly, the scope is rather wide and I too often lose track of which
    change had which effect.

    What I will continue to do is to post copies of the development stuff
    on sources (contrib/proxima) although I cannot vouch that older
    postings will still be viable if I have not looked at them for a
    while.

    I am documenting what I feel is important and will be posting here a
    couple of RFCs as soon as I have an infrastructure that is more stable
    than right now.


  2. Re: [9fans] APE exit()

    >It seems that exit() performs a kill() that causes the window in
    >which, in this case, ldapsearch runs to close. Using _EXITS(0)


    does it do a setsid()? either way i can't see how it can destroy the window,
    but unless it does setsid() its call to exit shouldn't then call kill

  3. Re: [9fans] APE exit()

    >>It seems that exit() performs a kill() that causes the window in
    >>which, in this case, ldapsearch runs to close. Using _EXITS(0)

    >
    > does it do a setsid()? either way i can't see how it can destroy the window,
    > but unless it does setsid() its call to exit shouldn't then call kill


    I'll have to look. I fear Unix and Plan 9 process control are a bit
    of a mystery to me, but I can check the sources, of course.

    And I agree with you that it shouldn't destroy the window, but it is
    the type of inconvenient behaviour that one can't help noticing. In
    ACME/win it is slightly different, but I think analogous. Thanks for
    putting me on some sort of track.

    ++L


  4. Re: [9fans] APE exit()

    I think I figured that one out.

    /sys/src/ape/lib/ap/plan9/_buf.c:66 sets _killmuxsid() to be called
    during exit, then forks the process nodefile. this is all fine until
    exit time, when there is a race: _killmuxsid is called and tries to
    kill the child via kill(-pidgroup) but the child has already exited.
    kill() calls setpgid() on itself trying to become the same group as
    the child, but since the child has exited setpgid() fails (there is no
    such group anymore). kill() will then happily proceed and send SIGTERM
    to the original note group with which it was born, which unfortunately
    is the same notegroup of the shell, hence killing them both.

    a proposed fix for /sys/src/ape/lib/ap/plan9/kill.c:

    49,54c49,51
    < if(setpgid(mpid, -pid) > 0) {
    < r = note(mpid, msg, "/proc/%d/notepg");
    < setpgid(mpid, sid);
    < } else {
    < r = -1;
    < }
    ---
    > setpgid(mpid, -pid);
    > r = note(mpid, msg, "/proc/%d/notepg");
    > setpgid(mpid, sid);


  5. Re: [9fans] APE exit()

    > I think I figured that one out.

    Cool, I'll give you some feedback as soon as I can test it this side.
    It would make all the difference, to me.

    ++L


  6. Re: [9fans] APE exit()

    > a proposed fix for /sys/src/ape/lib/ap/plan9/kill.c:

    Worked a treat. Thank you, Andrey, very, very much.

    I now have functional OpenLDAP client tools and libraries. If anyone
    else needs them, please contact me. I'll be rebuilding them to
    tighten down the procedure, but I can provide working versions for the
    386. I'd be curious, if anyone has alternative architectures handy,
    to have them tested on different platforms.

    ++L


+ Reply to Thread