• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 24160618980

08 Apr 2026 09:52PM UTC coverage: 56.325%. First build
24160618980

Pull #7483

github

web-flow
Merge 37610cb4b into 2c799643d
Pull Request #7483: refactor: replace ps-based process handling with process manager

172 of 309 new or added lines in 7 files covered. (55.66%)

10473 of 18594 relevant lines covered (56.32%)

6.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.67
/lib/Service/Process/ProcessSignaler.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Service\Process;
10

11
use Psr\Log\LoggerInterface;
12

13
class ProcessSignaler {
14
        public function __construct(
15
                private LoggerInterface $logger,
16
        ) {
17
        }
82✔
18

19
        public function isRunning(int $pid): bool {
20
                if ($pid <= 0) {
3✔
21
                        return false;
3✔
22
                }
23

NEW
24
                if (function_exists('posix_kill')) {
×
NEW
25
                        return @posix_kill($pid, 0);
×
26
                }
27

NEW
28
                if (!function_exists('exec')) {
×
NEW
29
                        return false;
×
30
                }
31

32
                try {
NEW
33
                        exec(sprintf('kill -0 %d 2>/dev/null', $pid), $output, $exitCode);
×
NEW
34
                        return $exitCode === 0;
×
NEW
35
                } catch (\Throwable $e) {
×
NEW
36
                        $this->logger->debug('Failed to probe process status', [
×
NEW
37
                                'pid' => $pid,
×
NEW
38
                                'error' => $e->getMessage(),
×
NEW
39
                        ]);
×
NEW
40
                        return false;
×
41
                }
42
        }
43

44
        public function stopPid(int $pid, int $signal = SIGTERM): bool {
45
                if ($pid <= 0) {
2✔
46
                        return false;
2✔
47
                }
48

NEW
49
                if (function_exists('posix_kill')) {
×
NEW
50
                        return @posix_kill($pid, $signal);
×
51
                }
52

NEW
53
                if (!function_exists('exec')) {
×
NEW
54
                        return false;
×
55
                }
56

57
                try {
NEW
58
                        exec(sprintf('kill -%d %d 2>/dev/null', $signal, $pid), $output, $exitCode);
×
NEW
59
                        return $exitCode === 0;
×
NEW
60
                } catch (\Throwable $e) {
×
NEW
61
                        $this->logger->debug('Failed to terminate process', [
×
NEW
62
                                'pid' => $pid,
×
NEW
63
                                'signal' => $signal,
×
NEW
64
                                'error' => $e->getMessage(),
×
NEW
65
                        ]);
×
NEW
66
                        return false;
×
67
                }
68
        }
69

70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc