Skip to content

hanjoes/swift-daemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftDaemon

Daemonize a given routine.

"fork" is "hidden" from user by Swift, I stole a piece of code from project Curassow to re-surface the "fork" system call in Swift.

Usage

import SwiftDaemon

SwiftDaemon.daemonize(inDir: "/tmp") {
  let fd = fopen("SwiftDaemonTest.log", "w")
  defer { fclose(fd) }
  for _ in 1...10 {
    usleep(1000000)
    let content = "Test\n"
    fwrite(content, 1, content.count, fd)
    fflush(fd)
  }
}

About

Daemonize a given routine.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages