Simple multi-threading

Discussion in 'C++' started by howa, Jun 21, 2008.

  1. howa

    howa Guest

    Currently I have a single threaded server, developed using C, serving
    multiple client at the same time, now I want a new feature:

    a. I need to execute a particular program at some point, e.g.
    email.exe
    b. the email.exe might need some time to finish, so it block my main
    program
    c. I don't need to collect the output from email.exe, just best-effort-
    executed is okay

    Without changing my program to a multi-threaded program, I am not sure
    if it is recommended to execute the email.exe using system + at
    command.

    I mean if it is scalable and reliable.


    Thanks.
     
    howa, Jun 21, 2008
    #1
    1. Advertising

  2. howa

    Jerry Coffin Guest

    In article <e4556b25-c388-424b-925e-
    >, says...

    [ starting an external program asynchronously ... ]

    > Without changing my program to a multi-threaded program, I am not sure
    > if it is recommended to execute the email.exe using system + at
    > command.
    >
    > I mean if it is scalable and reliable.


    There's no particular reason is shouldn't work, but it's not what I'd
    recommend -- I'd probably call CreateProcess, though you could consider
    ShellExecute, ShellExecuteEx, WinExec, etc. Using these you can fairly
    easily detect a truly catastrophic failure, such as the executable
    you're trying to use not existing, while still avoiding waiting for it
    to finish executing or anything like that.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Jun 21, 2008
    #2
    1. Advertising

  3. howa

    James Kanze Guest

    On Jun 21, 4:44 pm, howa <> wrote:
    > Currently I have a single threaded server, developed using C, serving
    > multiple client at the same time, now I want a new feature:


    > a. I need to execute a particular program at some point, e.g.
    > email.exe
    > b. the email.exe might need some time to finish, so it block my main
    > program
    > c. I don't need to collect the output from email.exe, just best-effort-
    > executed is okay


    > Without changing my program to a multi-threaded program, I am not sure
    > if it is recommended to execute the email.exe using system + at
    > command.


    > I mean if it is scalable and reliable.


    I'm not too sure what the question is. If the system supports
    it, you can definitely start a program in background using the
    system command; something like ``system( "mail &" )'' will work
    on all Unix systems I know. (Actually, it won't, because
    without any furthre arguments, "mail" is interactive. But if
    you give it the name of a file to be sent, and where to send it,
    there's no problem.) I can hardly imagine that the situation
    would be different with any other OS (but I don't know offhand
    how to start a program in background using system under
    Windows).

    --
    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, Jun 22, 2008
    #3
    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. Replies:
    38
    Views:
    1,307
    Dennis Lee Bieber
    Feb 15, 2005
  2. Replies:
    9
    Views:
    1,102
    Mark Space
    Dec 29, 2007
  3. Steven Woody
    Replies:
    0
    Views:
    453
    Steven Woody
    Jan 9, 2009
  4. Steven Woody
    Replies:
    0
    Views:
    468
    Steven Woody
    Jan 9, 2009
  5. akineko
    Replies:
    3
    Views:
    2,705
    Jesse Noller
    Jan 29, 2009
Loading...

Share This Page