Link to home
Start Free TrialLog in
Avatar of nisa
nisa

asked on

How do I prevent multiple instances of same process to run at the same time?

Hello,
    I would like to know the proper way to prevent the same instance of processes from running at the same time on UNIX. I would like to allow only one instance of process to run. If the same program were to execute again, it will check if there is same instance already running. If yes, then it will immediately terminate itself.

Best regards,
Nisa.
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nisa
nisa

ASKER

Tintin,
    I accept the answer, thanks!. I have another question, I will give u extra 50 pts for that (if u have the info):

I know that we can use unix "system()" call ie system(<the script command here>) so that my C program can call it internally. Is there any alternative I can use ie by using unix call directly (without using the script) from the C program?

Best regards,
Azmi.
Your additional question depends entirely on what the script is doing.

There are a lot of commands that have C library equivalents, it all depends on what functions you are trying to do.