using exec to start smbclient, replaces the need to kill forked procs

This commit is contained in:
raffis 2019-03-28 14:45:43 +01:00
commit e30d3afd08
No known key found for this signature in database
GPG key ID: 5E0BF46A67AD81C4
2 changed files with 4 additions and 13 deletions

View file

@ -173,18 +173,6 @@ class RawConnection {
return; return;
} }
if ($terminate) { if ($terminate) {
// if for case that posix_ functions are not available
if (function_exists('posix_kill')) {
$status = proc_get_status($this->process);
$ppid = $status['pid'];
$pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`);
foreach ($pids as $pid) {
if (is_numeric($pid)) {
//9 is the SIGKILL signal
posix_kill($pid, 9);
}
}
}
proc_terminate($this->process); proc_terminate($this->process);
} }
proc_close($this->process); proc_close($this->process);

View file

@ -55,6 +55,8 @@ class Share extends AbstractShare {
FileInfo::MODE_SYSTEM => 's' FileInfo::MODE_SYSTEM => 's'
]; ];
const EXEC_CMD = 'exec';
/** /**
* @param IServer $server * @param IServer $server
* @param string $name * @param string $name
@ -78,7 +80,8 @@ class Share extends AbstractShare {
protected function getConnection() { protected function getConnection() {
$command = sprintf( $command = sprintf(
'%s%s -t %s %s %s %s', '%s %s%s -t %s %s %s %s',
self::EXEC_CMD,
$this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '', $this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '',
$this->system->getSmbclientPath(), $this->system->getSmbclientPath(),
$this->server->getOptions()->getTimeout(), $this->server->getOptions()->getTimeout(),