@@ -88,14 +88,14 @@ extension Configuration {
88
88
89
89
// Spawn
90
90
var pid : pid_t = 0
91
- var processFileDescriptor : PlatformFileDescriptor = - 1
91
+ var processDescriptor : PlatformFileDescriptor = - 1
92
92
let spawnError : CInt = possibleExecutablePath. withCString { exePath in
93
93
return ( self . workingDirectory? . string) . withOptionalCString { workingDir in
94
94
return supplementaryGroups. withOptionalUnsafeBufferPointer { sgroups in
95
95
return fileDescriptors. withUnsafeBufferPointer { fds in
96
96
return _subprocess_fork_exec (
97
97
& pid,
98
- & processFileDescriptor ,
98
+ & processDescriptor ,
99
99
exePath,
100
100
workingDir,
101
101
fds. baseAddress!,
@@ -145,7 +145,7 @@ extension Configuration {
145
145
let execution = Execution (
146
146
processIdentifier: . init(
147
147
value: pid,
148
- processFileDescriptor : processFileDescriptor
148
+ processDescriptor : processDescriptor
149
149
)
150
150
)
151
151
return SpawnResult (
@@ -191,16 +191,16 @@ extension Configuration {
191
191
public struct ProcessIdentifier : Sendable , Hashable {
192
192
/// The platform specific process identifier value
193
193
public let value : pid_t
194
- internal let processFileDescriptor : PlatformFileDescriptor
194
+ internal let processDescriptor : PlatformFileDescriptor
195
195
196
- internal init ( value: pid_t , processFileDescriptor : PlatformFileDescriptor ) {
196
+ internal init ( value: pid_t , processDescriptor : PlatformFileDescriptor ) {
197
197
self . value = value
198
- self . processFileDescriptor = processFileDescriptor
198
+ self . processDescriptor = processDescriptor
199
199
}
200
200
201
201
internal func close( ) {
202
- if self . processFileDescriptor > 0 {
203
- _SubprocessCShims. close ( self . processFileDescriptor )
202
+ if self . processDescriptor > 0 {
203
+ _SubprocessCShims. close ( self . processDescriptor )
204
204
}
205
205
}
206
206
}
@@ -304,16 +304,16 @@ internal func monitorProcessTermination(
304
304
// pidfd is only supported on Linux kernel 5.4 and above
305
305
// On older releases, use signalfd so we do not need
306
306
// to register anything with epoll
307
- if processIdentifier. processFileDescriptor > 0 {
308
- // Register processFileDescriptor with epoll
307
+ if processIdentifier. processDescriptor > 0 {
308
+ // Register processDescriptor with epoll
309
309
var event = epoll_event (
310
310
events: EPOLLIN . rawValue,
311
- data: epoll_data ( fd: processIdentifier. processFileDescriptor )
311
+ data: epoll_data ( fd: processIdentifier. processDescriptor )
312
312
)
313
313
let rc = epoll_ctl (
314
314
storage. epollFileDescriptor,
315
315
EPOLL_CTL_ADD,
316
- processIdentifier. processFileDescriptor ,
316
+ processIdentifier. processDescriptor ,
317
317
& event
318
318
)
319
319
if rc != 0 {
@@ -326,7 +326,7 @@ internal func monitorProcessTermination(
326
326
}
327
327
// Now save the registration
328
328
var newState = storage
329
- newState. continuations [ processIdentifier. processFileDescriptor ] = continuation
329
+ newState. continuations [ processIdentifier. processDescriptor ] = continuation
330
330
state = . started( newState)
331
331
// No state to resume
332
332
return nil
@@ -342,7 +342,7 @@ internal func monitorProcessTermination(
342
342
if siginfo. si_pid == 0 && siginfo. si_signo == 0 {
343
343
// Save this continuation to be called by signal hander
344
344
var newState = storage
345
- newState. continuations [ processIdentifier. processFileDescriptor ] = continuation
345
+ newState. continuations [ processIdentifier. processDescriptor ] = continuation
346
346
state = . started( newState)
347
347
return nil
348
348
}
@@ -421,7 +421,7 @@ private extension siginfo_t {
421
421
// Okay to be unlocked global mutable because this value is only set once like dispatch_once
422
422
private nonisolated ( unsafe) var _signalPipe: ( readEnd: CInt , writeEnd: CInt ) = ( readEnd: - 1 , writeEnd: - 1 )
423
423
// Okay to be unlocked global mutable because this value is only set once like dispatch_once
424
- private nonisolated ( unsafe) var _waitProcessFileDescriptorSupported = false
424
+ private nonisolated ( unsafe) var _waitprocessDescriptorSupported = false
425
425
private let _processMonitorState : Mutex < ProcessMonitorState > = . init( . notStarted)
426
426
427
427
private func shutdown( ) {
@@ -520,8 +520,8 @@ private func monitorThreadFunc(args: UnsafeMutableRawPointer?) -> UnsafeMutableR
520
520
}
521
521
522
522
// P_PIDFD requires Linux Kernel 5.4 and above
523
- if _waitProcessFileDescriptorSupported {
524
- _blockAndWaitForProcessFileDescriptor ( targetFileDescriptor, context: context)
523
+ if _waitprocessDescriptorSupported {
524
+ _blockAndWaitForprocessDescriptor ( targetFileDescriptor, context: context)
525
525
} else {
526
526
_reapAllKnownChildProcesses ( targetFileDescriptor, context: context)
527
527
}
@@ -573,7 +573,7 @@ private let setup: () = {
573
573
574
574
// If the current kernel does not support pidfd, fallback to signal handler
575
575
// Create the self-pipe that signal handler writes to
576
- if !_isWaitProcessFileDescriptorSupported ( ) {
576
+ if !_isWaitprocessDescriptorSupported ( ) {
577
577
var pipeCreationError : SubprocessError ? = nil
578
578
do {
579
579
let ( readEnd, writeEnd) = try FileDescriptor . pipe ( )
@@ -612,7 +612,7 @@ private let setup: () = {
612
612
}
613
613
} else {
614
614
// Mark waitid(P_PIDFD) as supported
615
- _waitProcessFileDescriptorSupported = true
615
+ _waitprocessDescriptorSupported = true
616
616
}
617
617
let monitorThreadContext = MonitorThreadContext (
618
618
epollFileDescriptor: epollFileDescriptor,
@@ -645,7 +645,7 @@ private func _setupMonitorSignalHandler() {
645
645
setup
646
646
}
647
647
648
- private func _blockAndWaitForProcessFileDescriptor ( _ pidfd: CInt , context: MonitorThreadContext ) {
648
+ private func _blockAndWaitForprocessDescriptor ( _ pidfd: CInt , context: MonitorThreadContext ) {
649
649
var terminationStatus : Result < TerminationStatus , SubprocessError >
650
650
651
651
var siginfo = siginfo_t ( )
@@ -760,7 +760,7 @@ private func _reapAllKnownChildProcesses(_ signalFd: CInt, context: MonitorThrea
760
760
}
761
761
}
762
762
763
- internal func _isWaitProcessFileDescriptorSupported ( ) -> Bool {
763
+ internal func _isWaitprocessDescriptorSupported ( ) -> Bool {
764
764
// waitid(P_PIDFD) is only supported on Linux kernel 5.4 and above
765
765
// Prob whether the current system supports it by calling it with self pidfd
766
766
// and checking for EINVAL (waitid sets errno to EINVAL if it does not
0 commit comments