(file *os.File)
| 377 | } |
| 378 | |
| 379 | func lockFile(file *os.File) error { |
| 380 | lockResult := make(chan error) |
| 381 | |
| 382 | go func() { |
| 383 | err := syscall.Flock(int(file.Fd()), syscall.LOCK_EX) |
| 384 | lockResult <- err |
| 385 | }() |
| 386 | |
| 387 | select { |
| 388 | case err := <-lockResult: |
| 389 | if err != nil { |
| 390 | file.Close() |
| 391 | return fmt.Errorf("failed to lock file: %w", err) |
| 392 | } |
| 393 | return nil |
| 394 | |
| 395 | case <-time.After(fileLockTimeout): |
| 396 | file.Close() |
| 397 | return fmt.Errorf("process-compose file lock timed out after %d seconds", fileLockTimeout/time.Second) |
| 398 | } |
| 399 | } |
no outgoing calls
no test coverage detected