Simple multi-threading

H

howa

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.
 
J

Jerry Coffin

[ 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.
 
J

James Kanze

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).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top