Skip to content

About

Concurrent shell scripting framework with deep support for async/await.

Topics

Resources

Stars

67 stars

Watchers

5 watching

Forks

Latest commit

 

History

121 Commits

Folders and files

Repository files navigation

SwiftSlash 🚀

Swift Compatibility Platforms

Dependency-free, high-performance concurrent shell framework for Swift 6.0+

SwiftSlash 4.0 is a pure-Swift library (zero external dependencies) designed for rock-solid reliability and speed. Its internal engine ensures:

  • 🔒 Memory Safety: Automatic cleanup of file descriptors and subprocesses guarantees no memory leaks or zombie processes.
  • ⚡ Blazing Performance: Fast process startup, I/O streaming, and internal scheduling without per-process event loops.
  • 🔄 True Concurrency: Run hundreds or thousands of shell commands in parallel, leveraging Swift’s async/await for minimal overhead.
  • 🛡 Secure Execution: Isolated handles and controlled working-directory management ensure a hardened runtime.
  • 📦 Type-Safe API: Leveraging Swift 6.0/6.1’s advanced type system for compile-time correctness and clear intent.
  • 🛑 Native Task Cancellation: Cancelling the awaiting Task terminates the child process and, when its placement gives it one, its entire process group — then reaps all resources and surfaces CancellationError. No orphaned or zombie processes.
  • 🧬 Process-Group Control: Every launch decides where its child sits — its own process group, the launcher's group (so an outer teardown cascades through a nested launch), or a detached session that outlives it. A launch that runs inside another launch resolves this automatically, so grandchildren are never left running after the caller has given up.

📚 Documentation

Full DocC documentation is available at swiftslash.com/documentation.

🔌 Bring Your Own Data Channels

Don't want SwiftSlash's built-in stdio pipeline for a given process? Hand it a file descriptor you already own — SwiftNIO, sockets, PTYs, or anything else — and SwiftSlash binds it to the child and stays out of the data path entirely. Reaping and cancellation remain fully intact.

import Foundation
import SwiftSlash

let pipe = Pipe()
let child = ChildProcess(
    try Command("/bin/cat"),
    dataChannels: [
        STDIN_FILENO: .read(.byo(fd: .init(rawValue: pipe.fileHandleForReading.fileDescriptor))),
        STDOUT_FILENO: .write(.byo(fd: .init(rawValue: pipe.fileHandleForWriting.fileDescriptor))),
        STDERR_FILENO: .write(.byo(fd: .init(rawValue: pipe.fileHandleForWriting.fileDescriptor)))
    ]
)
async let exit = child.run()
// ... drive `pipe` with SwiftNIO (or anything else) — SwiftSlash never touches it.

See the BYO Data Channels article for the full ownership contract.

🤝 Contributing

We welcome bug reports, feature requests, and pull requests.

📄 License

SwiftSlash is released under the MIT License. See LICENSE for details.

📬 Contact

Stay up to date or ask questions on Twitter: @tannerdsilva

About

Concurrent shell scripting framework with deep support for async/await.

Topics

Resources

Stars

67 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages