My DLL wants to close the program in which it's running

Discussion in 'C++' started by Robert Rollins, Jul 10, 2007.

  1. Hi all,
    I'm writing some additions to an existing C++ DLL, and one of the
    things I need to add is a generic way to close down the program in
    which my DLL is running (so I can close down whatever program may have
    loaded it). Can I just call exit(0)? That seems like a really
    dramatic way to go about this, and I'm thinking that it might be a bad
    idea. Any advice would be greatly appreciated.
     
    Robert Rollins, Jul 10, 2007
    #1
    1. Advertising

  2. Robert Rollins

    red floyd Guest

    Robert Rollins wrote:
    > Hi all,
    > I'm writing some additions to an existing C++ DLL, and one of the
    > things I need to add is a generic way to close down the program in
    > which my DLL is running (so I can close down whatever program may have
    > loaded it). Can I just call exit(0)? That seems like a really
    > dramatic way to go about this, and I'm thinking that it might be a bad
    > idea. Any advice would be greatly appreciated.
    >


    Wrong group. The C++ Standard (ISO/IEC 14882:2003) doesn't discuss
    DLLs. Try a group with windows or microsoft in the name. See FAQ 5.9

    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9
     
    red floyd, Jul 10, 2007
    #2
    1. Advertising

  3. Robert Rollins

    Herhor Guest

    Dnia 10-07-2007 o 07:36:21 red floyd <> napisa³(a):

    > Robert Rollins wrote:
    >> Hi all,
    >> I'm writing some additions to an existing C++ DLL, and one of the
    >> things I need to add is a generic way to close down the program in
    >> which my DLL is running (so I can close down whatever program may have
    >> loaded it). Can I just call exit(0)? That seems like a really
    >> dramatic way to go about this, and I'm thinking that it might be a bad
    >> idea. Any advice would be greatly appreciated.
    >>

    >
    > Wrong group. The C++ Standard (ISO/IEC 14882:2003) doesn't discuss
    > DLLs. Try a group with windows or microsoft in the name. See FAQ 5.9
    >
    > http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9
    >


    Yes, but let's not be so orthodox like C-ircusians! ;)
     
    Herhor, Jul 10, 2007
    #3
  4. Robert Rollins

    BobR Guest

    red floyd <> wrote in message...
    > Robert Rollins wrote:
    > > Hi all,
    > > I'm writing some additions to an existing C++ DLL,

    [snip]
    > >

    >
    > Wrong group. The C++ Standard (ISO/IEC 14882:2003) doesn't discuss
    > DLLs. Try a group with windows or microsoft in the name. See FAQ 5.9
    >
    > http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9
    >


    But Red, I thought a 'Doubly Linked List' (std::list) WAS on topic here. <G>

    --
    Bob R
    POVrookie
     
    BobR, Jul 10, 2007
    #4
  5. Robert Rollins

    red floyd Guest

    BobR wrote:
    > red floyd <> wrote in message...
    >> Robert Rollins wrote:
    >>> Hi all,
    >>> I'm writing some additions to an existing C++ DLL,

    > [snip]
    >> Wrong group. The C++ Standard (ISO/IEC 14882:2003) doesn't discuss
    >> DLLs. Try a group with windows or microsoft in the name. See FAQ 5.9
    >>
    >> http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9
    >>

    >
    > But Red, I thought a 'Doubly Linked List' (std::list) WAS on topic here. <G>
    >


    From the OP:
    I'm writing some additions to an existing C++ DLL, and one of the
    > things I need to add is a generic way to close down the program in
    > which my DLL is running (so I can close down whatever program may have
    > loaded it). Can I just call exit(0)? That seems like a really
    > dramatic way to go about this, and I'm thinking that it might be a bad
    > idea. Any advice would be greatly appreciated.


    Where do you see "Doubly Linked List"? How to kill a process from
    within a DLL is OT.
     
    red floyd, Jul 10, 2007
    #5
  6. Robert Rollins

    red floyd Guest

    BobR wrote:
    >
    > But Red, I thought a 'Doubly Linked List' (std::list) WAS on topic here. <G>
    >


    DOH!!!!! Ignore my other reply to this. I missed the "<g>" marker :-(
    Good one!
     
    red floyd, Jul 10, 2007
    #6
  7. Robert Rollins

    BobR Guest

    red floyd <> wrote in message...
    > BobR wrote:
    > >
    > > But Red, I thought a 'Doubly Linked List' (std::list) WAS on topic here.

    <G>
    > >

    >
    > DOH!!!!! Ignore my other reply to this. I missed the "<g>" marker :-(
    > Good one!
    >


    Imagine the confusion we could create if every time some poor guy asks about
    a window$ DLL in this NG, we *wedge* in a 'std::list' answer. :-}

    I started to answer the OP with something like, "no, you don't need to use
    exit(), just let the instantiation go out of scope.". But.....

    --
    Bob R
    POVrookie
     
    BobR, Jul 10, 2007
    #7
  8. Robert Rollins

    James Kanze Guest

    On Jul 10, 2:43 am, Robert Rollins <> wrote:

    > I'm writing some additions to an existing C++ DLL, and one of the
    > things I need to add is a generic way to close down the program in
    > which my DLL is running (so I can close down whatever program may have
    > loaded it). Can I just call exit(0)? That seems like a really
    > dramatic way to go about this, and I'm thinking that it might be a bad
    > idea. Any advice would be greatly appreciated.


    There are only two standard ways to normally terminate a
    process: return from main, and call exit(). (There's also
    abort(), but I don't think we can consider that "normally
    terminating".) Generally, it's better to avoid calling exit(),
    since that means that the destructors of local variables aren't
    called, but unless the main routine has provided for some other
    conventions, there's not much else you can do. (In a number of
    my programs, I use the convention of throwing an int; main
    catch'es the int, and returns the value thrown. But this only
    works because main() establishes the convention.)

    BTW: you can ignore the idiots complaining about off topic.
    Your question is quite appropriate here. But some people just
    like to hear themselves talk, and since they can't think of
    anything else...

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jul 11, 2007
    #8
  9. Robert Rollins

    red floyd Guest

    James Kanze wrote:
    > On Jul 10, 2:43 am, Robert Rollins <> wrote:
    >
    >> I'm writing some additions to an existing C++ DLL, and one of the
    >> things I need to add is a generic way to close down the program in
    >> which my DLL is running (so I can close down whatever program may have
    >> loaded it). Can I just call exit(0)? That seems like a really
    >> dramatic way to go about this, and I'm thinking that it might be a bad
    >> idea. Any advice would be greatly appreciated.

    >
    > [redacted]
    >
    > BTW: you can ignore the idiots complaining about off topic.
    > Your question is quite appropriate here. But some people just
    > like to hear themselves talk, and since they can't think of
    > anything else...
    >


    No, James, I don't believe it's appropriate. Usage of exit() is
    definitely on topic. But the behavior of exit() when called from a DLL
    is specifically off topic.
     
    red floyd, Jul 11, 2007
    #9
  10. Robert Rollins

    Kai-Uwe Bux Guest

    red floyd wrote:

    > James Kanze wrote:
    >> On Jul 10, 2:43 am, Robert Rollins <> wrote:
    >>
    >>> I'm writing some additions to an existing C++ DLL, and one of the
    >>> things I need to add is a generic way to close down the program in
    >>> which my DLL is running (so I can close down whatever program may have
    >>> loaded it). Can I just call exit(0)? That seems like a really
    >>> dramatic way to go about this, and I'm thinking that it might be a bad
    >>> idea. Any advice would be greatly appreciated.

    >>
    >> [redacted]
    >>
    >> BTW: you can ignore the idiots complaining about off topic.
    >> Your question is quite appropriate here. But some people just
    >> like to hear themselves talk, and since they can't think of
    >> anything else...
    >>

    >
    > No, James, I don't believe it's appropriate. Usage of exit() is
    > definitely on topic. But the behavior of exit() when called from a DLL
    > is specifically off topic.


    I would hope that the behavior of exit() when called from within a DLL
    (whatever that may be) is not any different from what the standard has to
    say about the behavior of exit() when called; otherwise the implementation
    would seem to be non-conforming. Therefore, I do not see, how the answer to
    the question depends on the DLL-issue.

    As far as I can see, the OP mentioned DLLs just to indicate that he was
    prepared to hear that, from within DLLs, there are special rules. That the
    standard does not provide those rules does not render the question
    off-topic but just allows for a simpler answer.


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Jul 11, 2007
    #10
  11. Robert Rollins

    James Kanze Guest

    On Jul 11, 5:25 pm, red floyd <> wrote:
    > James Kanze wrote:
    > > On Jul 10, 2:43 am, Robert Rollins <> wrote:


    > >> I'm writing some additions to an existing C++ DLL, and one of the
    > >> things I need to add is a generic way to close down the program in
    > >> which my DLL is running (so I can close down whatever program may have
    > >> loaded it). Can I just call exit(0)? That seems like a really
    > >> dramatic way to go about this, and I'm thinking that it might be a bad
    > >> idea. Any advice would be greatly appreciated.


    > > [redacted]


    > > BTW: you can ignore the idiots complaining about off topic.
    > > Your question is quite appropriate here. But some people just
    > > like to hear themselves talk, and since they can't think of
    > > anything else...


    > No, James, I don't believe it's appropriate. Usage of exit() is
    > definitely on topic. But the behavior of exit() when called from a DLL
    > is specifically off topic.


    If the behavior were platform specific, agreed. It's not.
    Discussing details of a specific platform API is off topic, but
    talking about generally available features, like dynamic
    linking, are not off topic per se. Neither would be comparing
    implementations, or discussing what will be in the next version
    of the standard. Just because the symbol DLL happened to be in
    the posting doesn't make it off topic.

    The C++ standard actually tries to take DLL's into account, in
    one place (order of initialization). I don't think it really
    succeeds, and I don't think it should have, without completely
    addressing the issue.

    Note too that implicit dynamic linking is actually standard
    conformant, today. The standard doesn't say when the final
    phase of translation takes place, and as long as the the
    observable behavior is conform with what is required by the
    standard for the source code, an implementation can defer
    linking as long as it likes.

    --
    James Kanze (Gabi Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jul 11, 2007
    #11
  12. Robert Rollins

    red floyd Guest

    Kai-Uwe Bux wrote:
    > red floyd wrote:
    >
    >> James Kanze wrote:
    >>> On Jul 10, 2:43 am, Robert Rollins <> wrote:

    [redacted]
    >>>

    >> No, James, I don't believe it's appropriate. Usage of exit() is
    >> definitely on topic. But the behavior of exit() when called from a DLL
    >> is specifically off topic.

    >
    > I would hope that the behavior of exit() when called from within a DLL
    > (whatever that may be) is not any different from what the standard has to
    > say about the behavior of exit() when called; otherwise the implementation
    > would seem to be non-conforming. Therefore, I do not see, how the answer to
    > the question depends on the DLL-issue.
    >
    > As far as I can see, the OP mentioned DLLs just to indicate that he was
    > prepared to hear that, from within DLLs, there are special rules. That the
    > standard does not provide those rules does not render the question
    > off-topic but just allows for a simpler answer.
    >


    OK, I'll concede the point. Sorry if I came off as a bit of a pig.
     
    red floyd, Jul 11, 2007
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry III
    Replies:
    2
    Views:
    616
    Kathy Burke
    Aug 3, 2003
  2. Replies:
    27
    Views:
    844
    Riccardo Galli
    Jul 2, 2005
  3. daniel åkerud
    Replies:
    7
    Views:
    162
    Jari Williamsson
    Jan 25, 2008
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    951
    Iñaki Baz Castillo
    Jan 12, 2010
  5. libsfan01
    Replies:
    4
    Views:
    236
    Georgi Naumov
    Aug 5, 2006
Loading...

Share This Page