0

I have this code:

$process = Process::fromShellCommandline('bash ./receive.sh \
    url=' . env('SGW_URL') . ' \
    cert=certs/privateKey.p12?' . env('SGW_CERT_PASS'),
        '/var/www/sgwClientFiles/');

    $process->run();
    $process->getCommandLine();
    if (!$process->isSuccessful()) {
        throw new ProcessFailedException($process);
    }
    
    $process->stop(15);

    return $process;

and it doesn't stop after 15sec. Instead, I get 'exceeded the timeout of 60 seconds' error.

The thing is, that a command which I try to run from command line doesn't stop itself and it has to be stopped from the script. Any ideas why the method "stop()" doesn't function properly?

gp_sflover
  • 3,460
  • 5
  • 38
  • 48
Mr_T
  • 15
  • 1
  • 1
  • 4

1 Answers1

0

If anyone wonders, I solved this issue as follows:

$process->start();
    while (time() - $process->getStartTime() <= 15) {
        usleep(2000);
    }

    $process->stop();
Mr_T
  • 15
  • 1
  • 1
  • 4