mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
add example file
close smbclient connections properly
This commit is contained in:
parent
476980d4ce
commit
3a75f15ca3
3 changed files with 35 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
.idea
|
||||
vendor
|
||||
composer.lock
|
||||
|
|
|
|||
20
example.php
Normal file
20
example.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
use Icewind\SMB\NativeServer;
|
||||
use Icewind\SMB\Server;
|
||||
|
||||
require('vendor/autoload.php');
|
||||
|
||||
if (Server::NativeAvailable()) {
|
||||
$server = new NativeServer('localhost', 'test', 'test');
|
||||
} else {
|
||||
$server = new Server('localhost', 'test', 'test');
|
||||
}
|
||||
|
||||
$share = $server->getShare('test');
|
||||
|
||||
$share->put(__FILE__, 'example.php');
|
||||
|
||||
$files = $share->dir('/');
|
||||
foreach ($files as $file) {
|
||||
echo $file->getName() . "\n";
|
||||
}
|
||||
|
|
@ -149,6 +149,20 @@ class RawConnection {
|
|||
return;
|
||||
}
|
||||
if ($terminate) {
|
||||
$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)) {
|
||||
// try for case that posix_ functions are not available
|
||||
try {
|
||||
//9 is the SIGKILL signal
|
||||
posix_kill($pid, 9);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
proc_terminate($this->process);
|
||||
}
|
||||
proc_close($this->process);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue