PHP and C: to avoid to execute multiples processes of the same C program

59 views Asked by At

I am developing a PHP web interface to manage the GPIO of my Raspberry. I would like to create a page with for example four buttons:

  • Button 1: switch ON PIN1
  • Button 2: switch OFF PIN1
  • Button 3: switch ON PIN2
  • Button 4: switch OFF PIN2

To each button of the PHP page, I am associating a C program. So if i want to switch on the PIN1, I launch the PHP "exec" command of my program "switchOnPin1.c" and so on.

The problem is that in this way, after sometime, if I press many times the buttons, I have in my process list ("ps -aux" linux command) a lot of my C programs instances running.

Is there any way to have just one C program running so that for each button I can call always the same C program?

Thanks in advance

0

There are 0 answers