Skip to content

bakpakin/janet-proctools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

janet-proctools

A collection of modules for dealing with processes.

process module

Quick example

(import process)

(def redis-process 
  (process/spawn ["redis-server"] :redirects [[stderr stdout] [stdout (file/open "out.log" :wb)]]))

(process/signal redis-process :SIGTERM)

(process/wait redis-process)

(def buf (buffer/new 0))
(process/run ["echo" "hello"] :redirects [[stdout buf] [stderr :discard]])

sh module

Quick example

(import sh)

# raise an error on failure.
(sh/$ ["touch" "foo.txt"])

# raise an error on failure, return command output.
(sh/$$ ["echo" "hello world!"])
@"hello world!\n"

# return true or false depending on process success.
(when (sh/$? ["true"])
  (print "cool!"))

# shell helpers

(sh/shell-quote ["hello" "there ' \""])
"'hello' 'there '\\'' \"'"

(sh/pipeline [["ls"] ["sort" "-u"]])
@["/bin/sh" "-c" "'ls' | 'sort' '-u'"] # pass this to a run function.

About

A collection of janet modules for dealing with processes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%