Ending thread - OS2

This is a discussion on Ending thread - OS2 ; What's the correct way to end a thread which is used for a named pipe and is in blocking mode? I use _beginthread to start it and it seems the only way to exit is using DosKillThread. -- M Greene ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Ending thread

  1. Ending thread

    What's the correct way to end a thread which is used for a named pipe
    and is in blocking mode? I use _beginthread to start it and it seems
    the only way to exit is using DosKillThread.

    --

    M Greene Voice Memeber #1356

    IRC (MikeG): irc.va.webbnet.info #os/2 and #learnc++
    ashburn.va.us.undernet.org #os/2warp irc.ecomstation.com #eCS
    ICQ:319474014 AIM:mikekg2003

    http://members.cox.net/greenemk/os2/index.html

  2. Re: Ending thread

    Michael Greene wrote:
    > What's the correct way to end a thread which is used for a named pipe
    > and is in blocking mode? I use _beginthread to start it and it seems
    > the only way to exit is using DosKillThread.


    You mean it is blocked waiting on a pipe? If so, well, I would put
    something in the pipe that the thread would understand as "Do an
    exit(return), will ya?" ;-)

    Cheers,
    Martin

  3. Re: Ending thread

    MMI wrote:
    > Michael Greene wrote:
    >
    >> What's the correct way to end a thread which is used for a named pipe
    >> and is in blocking mode? I use _beginthread to start it and it seems
    >> the only way to exit is using DosKillThread.

    >
    >
    > You mean it is blocked waiting on a pipe? If so, well, I would put
    > something in the pipe that the thread would understand as "Do an
    > exit(return), will ya?" ;-)
    >
    > Cheers,
    > Martin


    Martin,

    I was thinking about that but I figure there might be a more "refined"
    way of ending - thanks


    --

    M Greene Voice Memeber #1356

    IRC (MikeG): irc.va.webbnet.info #os/2 and #learnc++
    ashburn.va.us.undernet.org #os/2warp irc.ecomstation.com #eCS
    ICQ:319474014 AIM:mikekg2003

    http://members.cox.net/greenemk/os2/index.html

  4. Re: Ending thread

    Michael Greene wrote:
    > MMI wrote:
    >
    >> Michael Greene wrote:
    >>
    >>> What's the correct way to end a thread which is used for a named pipe
    >>> and is in blocking mode? I use _beginthread to start it and it seems
    >>> the only way to exit is using DosKillThread.

    >>
    >> You mean it is blocked waiting on a pipe? If so, well, I would put
    >> something in the pipe that the thread would understand as "Do an
    >> exit(return), will ya?" ;-)

    >
    > Martin,
    >
    > I was thinking about that but I figure there might be a more "refined"
    > way of ending - thanks


    Breaking the pipe might be another option. Don't know if that's doable
    with a named pipe, per se, based on their shared nature.

    --
    [Reverse the parts of the e-mail address to reply.]


  5. Re: Ending thread

    Marty wrote:
    > Michael Greene wrote:
    >
    >> MMI wrote:
    >>
    >>> Michael Greene wrote:
    >>>
    >>>> What's the correct way to end a thread which is used for a named
    >>>> pipe and is in blocking mode? I use _beginthread to start it and it
    >>>> seems the only way to exit is using DosKillThread.
    >>>
    >>>
    >>> You mean it is blocked waiting on a pipe? If so, well, I would put
    >>> something in the pipe that the thread would understand as "Do an
    >>> exit(return), will ya?" ;-)

    >>
    >>
    >> Martin,
    >>
    >> I was thinking about that but I figure there might be a more "refined"
    >> way of ending - thanks

    >
    >
    > Breaking the pipe might be another option. Don't know if that's doable
    > with a named pipe, per se, based on their shared nature.
    >


    Tried that, sort of, but it did not work. I already had a shutdown in
    the pipe thread so I just open from the main thread and send shutdown.

    // Received ctrl+c so signal pipe thread shutdown
    if(signo == 4)
    {
    HPIPE SDSyslogPipe;
    ULONG ulAction;
    ULONG bytes_written;
    char buf_data[ ] = "PIPESHUTDOWN";

    DosOpen(PIPE_NAME, (PHFILE)&SDSyslogPipe, &ulAction, 0L, 0L,
    SC_PIPE_OPEN , SC_PIPE_MODE, NULL);
    DosWrite(SDSyslogPipe, buf_data, sizeof(buf_data), &bytes_written);
    DosClose(SDSyslogPipe);
    }

    --

    M Greene Voice Memeber #1356

    IRC (MikeG): irc.va.webbnet.info #os/2 and #learnc++
    ashburn.va.us.undernet.org #os/2warp irc.ecomstation.com #eCS
    ICQ:319474014 AIM:mikekg2003

    http://members.cox.net/greenemk/os2/index.html

  6. Re: Ending thread

    I think that if your blocked thread is in ConnectNmPipe, then just the
    close of the server handle is sufficient. If it's blocked in a read, I
    think you'll have to do DosKillThread (or else do the pipe write you
    discussed already).

+ Reply to Thread