Handbook
Glossary
unix
Factor handbook
»
The implementation
»
System interface
»
Operating system detection
Prev:
windows
Next:
windows
Vocabulary
system
Definition
IN:
system
UNION:
unix
macos
linux
freebsd
bsd
;
Methods
USING:
accessors
io.sockets.private
io.sockets.unix
kernel
system
unix.ffi
;
M:
unix
(broadcast)
dup
handle>>
SOL_SOCKET
SO_BROADCAST
set-socket-option
;
USING:
io.launcher
system
unix.ffi
;
M:
unix
(current-process)
getpid
;
USING:
destructors
io.sockets.private
io.sockets.unix
system
unix.ffi
;
M:
unix
(datagram)
[
SOCK_DGRAM
server-socket-fd
]
with-destructors
;
USING:
io.directories
io.directories.unix
kernel
sequences
system
unix.ffi
;
M:
unix
(directory-entries)
[
dirent
new
[
next-dirent
]
2curry
[
>directory-entry
]
produce
nip
]
with-unix-directory
;
USING:
accessors
math.order
system
tools.files
unix.groups
unix.users
;
M:
unix
(directory.)
<listing-tool>
{
+permissions+
+nlinks+
+user+
+group+
+file-size+
+file-date+
+file-name+
}
>>specs
{
{
directory-entry>>
name>>
<=>
}
}
>>sort
[
[
list-files
]
with-group-cache
]
with-user-cache
;
USING:
io.backend.unix
io.files
io.files.unix
io.ports
system
;
M:
unix
(file-appender)
open-append
<fd>
init-fd
<output-port>
;
USING:
io.backend.unix
io.files
io.files.unix
io.ports
system
;
M:
unix
(file-reader)
open-read
<fd>
init-fd
<input-port>
;
USING:
io.backend.unix
io.files
io.files.unix
io.ports
system
;
M:
unix
(file-writer)
open-write
<fd>
init-fd
<output-port>
;
USING:
io.backend.unix
io.files
io.files.unix
io.ports
system
;
M:
unix
(file-writer-secure)
open-secure-write
<fd>
init-fd
<output-port>
;
USING:
accessors
combinators
io.launcher
kernel
libc
system
unix.ffi
unix.process
;
M:
unix
(kill-process)
[
handle>>
SIGTERM
]
[
group>>
]
bi
{
{
+same-group+
[
kill
]
}
{
+new-group+
[
killpg
]
}
{
+new-session+
[
killpg
]
}
}
case
io-error
;
USING:
io.mmap.private
io.mmap.unix
system
unix.ffi
;
M:
unix
(mapped-file-r/w)
3 1
O_RDWR
mmap-open
;
USING:
io.mmap.private
io.mmap.unix
system
unix.ffi
;
M:
unix
(mapped-file-reader)
1 1
O_RDONLY
mmap-open
;
USING:
alien.c-types
alien.data
alien.strings
alien.utilities
environment
environment.unix
system
;
M:
unix
(os-envs)
environ
void*
deref
native-string-encoding
alien>strings
;
USING:
alien.c-types
alien.data
io.backend.unix
io.pipes
kernel
libc
sequences
system
unix.ffi
;
M:
unix
(pipe)
2
int
<c-array>
[
pipe
io-error
]
[
first2
[
<fd>
init-fd
]
bi@
pipe
boa
]
bi
;
USING:
destructors
io.sockets.private
io.sockets.unix
system
unix.ffi
;
M:
unix
(raw)
[
SOCK_RAW
server-socket-fd
]
with-destructors
;
USING:
io.sockets.private
io.sockets.unix
system
;
M:
unix
(receive-unsafe)
(receive-loop)
;
USING:
io.launcher
io.launcher.unix
kernel
system
unix.process
;
M:
unix
(run-process)
[
fork-process
]
curry
[
]
with-fork
;
USING:
accessors
io.sockets.private
io.sockets.unix
kernel
system
;
M:
unix
(send)
[
make-sockaddr/size-outgoing
]
[
[
handle>>
]
keep
]
bi*
do-send
;
USING:
alien.data
alien.utilities
environment
io.encodings.utf8
system
;
M:
unix
(set-os-envs)
utf8
strings>alien
malloc-byte-array
set-os-envs-pointer
;
USING:
io.backend.unix
io.files.unique.private
io.files.unique.unix
system
unix
;
M:
unix
(touch-unique-file)
open-unique-flags
file-mode
open-file
close-file
;
USING:
alien.c-types
alien.data
io.launcher
io.launcher.private
io.launcher.unix
kernel
math
system
unix.process
;
M:
unix
(wait-for-processes)
{
int
}
[
-1
swap
WNOHANG
waitpid
]
with-out-parameters
swap
dup
0
<=
[
2drop
t
]
[
find-process
dup
[
swap
code>status
notify-exit
f
]
[
2drop
f
]
if
]
if
;
USING:
accessors
destructors
io.files
io.ports
kernel
system
;
M:
unix
(wait-to-read)
dup
dup
handle>>
check-disposed
refill
dup
[
dupd
wait-for-port
(wait-to-read)
]
[
2drop
]
if
;
USING:
accessors
destructors
io.files
io.ports
kernel
system
;
M:
unix
(wait-to-write)
dup
dup
handle>>
check-disposed
drain
[
wait-for-port
]
[
drop
]
if*
;
USING:
alien.libraries
io.pathnames
system
;
M:
unix
>deployed-library-path
file-name
"$ORIGIN"
prepend-path
;
USING:
io.sockets.private
system
unix.ffi
;
M:
unix
addrinfo-error-string
gai_strerror
;
USING:
combinators
io.sockets
io.sockets.private
kernel
system
unix.ffi
;
M:
unix
addrspec-of-family
{
{
AF_INET
[
T{
ipv4
}
]
}
{
AF_INET6
[
T{
ipv6
}
]
}
{
AF_UNIX
[
T{
local
}
]
}
[
drop
f
]
}
case
;
USING:
elevate
kernel
math
system
unix.ffi
;
M:
unix
already-root?
getuid
geteuid
[
zero?
]
bi@
or
;
USING:
environment
io.standard-paths
splitting
system
;
M:
unix
application-directories
"PATH"
os-env
":"
split
;
USING:
accessors
io.backend.unix.multiplexers
kernel
namespaces
sequences
system
threads
x11.io
x11.io.unix
;
M:
unix
awaken-event-loop
dpy-fd
get
[
fd>>
mx
get-global
remove-input-callbacks
[
resume
]
each
]
when*
;
USING:
accessors
io.ports
kernel
system
unix.ffi
;
M:
unix
can-seek-handle?
fd>>
SEEK_CUR
0
lseek
-1
=
not
;
USING:
io.files.private
kernel
system
unix
unix.ffi
;
M:
unix
cd
[
chdir
]
unix-system-call
drop
;
USING:
accessors
io.mmap
kernel
libc
system
unix
unix.ffi
;
M:
unix
close-mapped-file
[
[
address>>
]
[
length>>
]
bi
munmap
io-error
]
[
handle>>
close-file
]
bi
;
USING:
mason.child
system
;
M:
unix
compile-factor-command
gnu-make-cmd
;
USING:
math.parser
sequences
system
system-info
zealot.factor
;
M:
unix
compile-factor-command
{
"make"
"-j"
}
cpus
number>string
suffix
;
USING:
generic
io.directories
io.files.info.unix
kernel
system
;
M:
unix
copy-file
[
M\
unix
copy-file
(call-next-method)
]
[
[
file-permissions
]
dip
swap
set-file-permissions
]
2bi
;
USING:
io.files.private
io.files.unix
system
;
M:
unix
cwd
4096
(cwd)
;
USING:
io.files.temp
io.pathnames
system
xdg
;
M:
unix
default-cache-directory
xdg-cache-home
"factor"
append-path
absolute-path
;
USING:
environment
io.files.temp
io.pathnames
sequences
system
;
M:
unix
default-temp-directory
"TMPDIR"
os-env
[
"/tmp"
]
when-empty
"factor-temp"
append-path
;
USING:
io.backend
io.directories
kernel
system
unix
unix.ffi
;
M:
unix
delete-directory
normalize-path
[
rmdir
]
unix-system-call
drop
;
USING:
io.backend
io.directories
system
unix
;
M:
unix
delete-file
normalize-path
unlink-file
;
USING:
combinators
kernel
namespaces
system
tools.deploy.backend
tools.deploy.config
tools.deploy.unix
;
M:
unix
deploy*
deploy-name
get
{
[
create-app-dir
]
[
drop
deployed-image-name
]
[
drop
namespace
make-deploy-image-executable
]
[
nip
""
[
copy-resources
]
[
copy-libraries
]
3bi
]
[
nip
maybe-open-deploy-directory
]
}
2cleave
;
USING:
io.backend
io.directories
io.pathnames
kernel
namespaces
system
tools.deploy.backend
tools.deploy.config
tools.deploy.config.editor
tools.deploy.unix
;
M:
unix
deploy-path
deploy-directory
get
[
dup
deploy-config
[
deploy-name
get
swap
?extension
append-path
normalize-path
]
with-variables
]
with-directory
;
USING:
anagrams
ascii
io.encodings.ascii
io.files
sequences
system
;
M:
unix
dict-words
"/usr/share/dict/words"
ascii
file-lines
[
>lower
]
map
;
USING:
alien.libraries
alien.libraries.unix
system
;
M:
unix
dlerror
(dlerror)
;
USING:
elevate
elevate.unix.private
kernel
system
;
M:
unix
elevated
2drop
posix-elevated
;
USING:
alien.libraries
environment.unix
system
;
M:
unix
environ
"environ"
f
address-of
;
USING:
system
zealot.factor
;
M:
unix
factor-path
"./factor"
;
USING:
mason.child
system
;
M:
unix
factor-path
"./factor"
;
USING:
io.files.info
io.files.info.unix.private
system
unix.ffi
;
M:
unix
file-executable?
X_OK
access?
;
USING:
io.backend
io.files.info
io.files.info.unix
system
unix.stat
;
M:
unix
file-info
normalize-path
file-status
stat>file-info
;
USING:
io.files.info
io.files.info.unix.private
system
unix.ffi
;
M:
unix
file-readable?
R_OK
access?
;
USING:
accessors
combinators
generic
io.files.info.unix
kernel
math.parser
sequences
system
tools.files
tools.files.unix.private
unix.groups
unix.users
;
M:
unix
file-spec>string
{
{
+file-name/type+
[
directory-entry>>
[
name>>
]
[
file-type>trailing
]
bi
append
]
}
{
+permissions+
[
file-info>>
permissions-string
]
}
{
+nlinks+
[
file-info>>
nlink>>
number>string
]
}
{
+user+
[
file-info>>
uid>>
user-name
]
}
{
+group+
[
file-info>>
gid>>
group-name
]
}
{
+uid+
[
file-info>>
uid>>
number>string
]
}
{
+gid+
[
file-info>>
gid>>
number>string
]
}
[
M\
unix
file-spec>string
(call-next-method)
]
}
case
;
USING:
io.backend
io.files.info
io.files.info.unix
kernel
system
;
M:
unix
file-system-info
normalize-path
[
new-file-system-info
]
dip
[
file-system-statfs
statfs>file-system-info
]
[
file-system-statvfs
statvfs>file-system-info
]
bi
file-system-calculations
;
USING:
io.files.info.unix
kernel
system
;
M:
unix
file-system-statfs
drop
f
;
USING:
io.files.info.unix
kernel
system
;
M:
unix
file-system-statvfs
drop
f
;
USING:
io.files.info
io.files.info.unix.private
system
unix.ffi
;
M:
unix
file-writable?
W_OK
access?
;
USING:
editors.geany
system
;
M:
unix
find-geany-path
"geany"
;
USING:
io.files
io.pathnames
io.standard-paths
kernel
sequences
system
;
M:
unix
find-in-path*
[
application-directories
]
dip
[
append-path
file-exists?
]
curry
find
nip
;
USING:
io.files
io.pathnames
io.standard-paths
io.standard-paths.unix
kernel
sequences
system
;
M:
unix
find-in-standard-login-path*
[
standard-login-paths
]
dip
[
append-path
file-exists?
]
curry
find
nip
;
USING:
editors.lite-xl
io.standard-paths
system
;
M:
unix
find-lite-xl-editor-path
"xl"
?find-in-path
;
USING:
editors.scite
io.standard-paths
system
;
M:
unix
find-scite-path
"scite"
?find-in-path
;
USING:
accessors
calendar
calendar.unix
math
system
;
M:
unix
gmt-offset
get-time
gmtoff>>
3600
/mod
60
/mod
;
USING:
accessors
io.ports
kernel
system
unix.stat
;
M:
unix
handle-length
fd>>
\
stat
new
[
fstat
-1
=
not
]
keep
swap
[
st_size>>
]
[
drop
f
]
if
;
USING:
environment
io.pathnames
system
;
M:
unix
home
"HOME"
os-env
;
USING:
alien.strings
byte-arrays
io.encodings.ascii
io.sockets
kernel
libc
system
unix.ffi
;
M:
unix
host-name
256
[
<byte-array>
dup
]
keep
gethostname
io-error
ascii
alien>string
;
USING:
etc-hosts
system
;
M:
unix
hosts-path
"/etc/hosts"
;
USING:
io.backend
io.backend.unix
io.ports
system
;
M:
unix
init-stdio
<stdin>
<input-port>
1
<fd>
<output-port>
2
<fd>
<output-port>
set-stdio
;
USING:
io.backend.unix
namespaces
system
x11
x11.io
x11.io.unix
x11.xlib
;
M:
unix
init-x-io
dpy
get
XConnectionNumber
<fd>
dpy-fd
set-global
;
USING:
accessors
dns
resolv-conf
system
;
M:
unix
initial-dns-servers
default-resolv.conf
nameserver>>
;
USING:
io.backend
io.backend.unix.multiplexers
namespaces
system
;
M:
unix
io-multiplex
mx
get-global
wait-for-events
;
USING:
io.backend
io.files.info
io.files.info.unix
system
unix.stat
;
M:
unix
link-info
normalize-path
link-status
stat>file-info
;
USING:
io.backend
io.directories
io.directories.unix
kernel
system
unix
unix.ffi
;
M:
unix
make-directory
normalize-path
mkdir-mode
[
mkdir
]
unix-system-call
drop
;
USING:
io.backend
io.files.links
kernel
system
unix
unix.ffi
;
M:
unix
make-hard-link
normalize-path
[
link
]
unix-system-call
drop
;
USING:
io.backend
io.files.links
kernel
system
unix
unix.ffi
;
M:
unix
make-link
normalize-path
[
symlink
]
unix-system-call
drop
;
USING:
accessors
continuations
io.directories
kernel
libc
system
;
M:
unix
move-file
[
move-file-atomically
]
[
dup
errno>>
EXDEV
=
[
drop
[
copy-file
]
[
drop
delete-file
]
2bi
]
[
rethrow
]
if
]
recover
;
USING:
io.backend
io.directories
kernel
system
unix
unix.ffi
;
M:
unix
move-file-atomically
[
normalize-path
]
bi@
[
rename
]
unix-system-call
drop
;
USING:
alien.strings
io.encodings.utf8
system
;
M:
unix
native-string-encoding
utf8
;
USING:
io.files.info.unix
kernel
system
;
M:
unix
new-file-info
unix-file-info
new
;
USING:
io.files.info.unix
kernel
system
;
M:
unix
new-file-system-info
unix-file-system-info
new
;
USING:
kernel
system
unix.users
;
M:
unix
new-passwd
passwd
new
;
USING:
kernel
system
unix.utmpx
;
M:
unix
new-utmpx-record
utmpx-record
new
;
USING:
io.backend.unix
io.sockets.secure
system
;
M:
unix
non-ssl-socket?
fd?
;
USING:
calendar
calendar.unix
system
;
M:
unix
now-gmt
current-timeval
timeval>unix-time
;
USING:
system
unix
unix.ffi
;
M:
unix
open-file
[
open
]
unix-system-call
;
USING:
environment
system
unix.ffi
;
M:
unix
os-env
getenv
;
USING:
accessors
combinators
kernel
system
unix.users
;
M:
unix
passwd>new-passwd
[
new-passwd
]
dip
{
[
pw_name>>
>>user-name
]
[
pw_passwd>>
>>password
]
[
pw_uid>>
>>uid
]
[
pw_gid>>
>>gid
]
[
pw_gecos>>
>>gecos
]
[
pw_dir>>
>>dir
]
[
pw_shell>>
>>shell
]
}
cleave
;
USING:
io.backend
io.files.links
system
unix
;
M:
unix
read-link
normalize-path
read-symbolic-link
;
USING:
io.files
io.files.links
io.pathnames
kernel
sequences
system
;
M:
unix
resolve-symlinks
path-components
"/"
[
append-path
dup
file-exists?
[
follow-links
]
when
]
reduce
;
USING:
system
tools.scaffold
;
M:
unix
scaffold-emacs
".emacs"
scaffold-rc
;
USING:
accessors
combinators
io
io.ports
kernel
system
unix
unix.ffi
;
M:
unix
seek-handle
swap
{
{
seek-absolute
[
SEEK_SET
]
}
{
seek-relative
[
SEEK_CUR
]
}
{
seek-end
[
SEEK_END
]
}
[
bad-seek-type
]
}
case
[
fd>>
swap
]
dip
[
lseek
]
unix-system-call
drop
;
USING:
calendar
formatting
io
io.backend
io.directories
io.encodings.utf8
io.files
io.files.trash
io.files.trash.unix.private
io.pathnames
kernel
sequences
system
;
M:
unix
send-to-trash
normalize-path
dup
trash-path
[
"files"
append-path
[
make-user-directory
]
keep
to-directory
safe-file-name
]
[
"info"
append-path
[
make-user-directory
]
keep
to-directory
".trashinfo"
append
overd
utf8
[
"[Trash Info]"
print
"Path="
write
print
"DeletionDate="
write
now
"%Y-%m-%dT%H:%M:%S"
strftime
print
]
with-file-writer
]
bi
move-file
;
USING:
environment
kernel
libc
system
unix.ffi
;
M:
unix
set-os-env
over
[
swap
1
setenv
io-error
]
[
nip
unset-os-env
]
if
;
USING:
environment
environment.unix
system
;
M:
unix
set-os-envs-pointer
environ
set-void*
;
USING:
calendar
kernel
libc
math
system
time
time.unix
unix.time
;
M:
unix
set-system-time
[
unix-1970
time-
duration>microseconds
>integer
make-timeval
]
[
timestamp>timezone
]
bi
settimeofday
io-error
;
USING:
debugger
io
kernel
prettyprint
sequences
system
unix.signals
;
M:
unix
signal-error.
"Unix signal #"
write
third
[
pprint
]
[
signal-name.
]
bi
nl
;
USING:
classes.struct
combinators
io.sockets.private
kernel
system
unix.ffi
;
M:
unix
sockaddr-of-family
{
{
AF_INET
[
sockaddr-in
memory>struct
]
}
{
AF_INET6
[
sockaddr-in6
memory>struct
]
}
{
AF_UNIX
[
sockaddr-un
memory>struct
]
}
[
2drop
f
]
}
case
;
USING:
accessors
io.sockets.secure
system
;
M:
unix
socket-handle
fd>>
;
USING:
accessors
calendar.unix
combinators
io.files.info.unix
kernel
math
system
;
M:
unix
stat>file-info
[
new-file-info
]
dip
{
[
stat>type
>>type
]
[
st_size>>
>>size
]
[
st_mode>>
>>permissions
]
[
st_ctimespec>>
timespec>unix-time
>>created
]
[
st_mtimespec>>
timespec>unix-time
>>modified
]
[
st_atimespec>>
timespec>unix-time
>>accessed
]
[
st_uid>>
>>uid
]
[
st_gid>>
>>gid
]
[
st_dev>>
>>dev
]
[
st_ino>>
>>ino
]
[
st_nlink>>
>>nlink
]
[
st_rdev>>
>>rdev
]
[
st_blocks>>
>>blocks
]
[
st_blksize>>
>>blocksize
]
[
drop
dup
blocks>>
standard-unix-block-size
*
>>size-on-disk
]
}
cleave
;
USING:
accessors
io.files.info.unix
system
;
M:
unix
stat>type
st_mode>>
n>file-type
;
USING:
io.files.info.unix
kernel
system
;
M:
unix
statfs>file-system-info
drop
;
USING:
io.files.info.unix
kernel
system
;
M:
unix
statvfs>file-system-info
drop
;
USING:
accessors
io.ports
kernel
libc
system
unix
unix.ffi
;
M:
unix
tell-handle
fd>>
0
SEEK_CUR
[
lseek
]
unix-system-call
[
io-error
]
[
]
bi
;
USING:
io.backend
io.backend.unix
io.directories
io.directories.unix
io.files
kernel
system
unix
;
M:
unix
touch-file
normalize-path
dup
file-exists?
[
touch
]
[
touch-mode
file-mode
open-file
close-file
]
if
;
USING:
io.backend
io.directories
kernel
system
unix
unix.ffi
;
M:
unix
truncate-file
[
normalize-path
]
dip
[
truncate
]
unix-system-call
drop
;
USING:
environment
libc
system
unix.ffi
;
M:
unix
unset-os-env
unsetenv
io-error
;
USING:
io.files
namespaces
system
x11.io
x11.io.unix
;
M:
unix
wait-for-display
dpy-fd
get
+input+
wait-for-fd
;
USING:
combinators
io.backend.unix
io.backend.unix.multiplexers
io.files
kernel
namespaces
system
threads
;
M:
unix
wait-for-fd
dup
+retry+
eq?
[
2drop
]
[
[
[
self
]
dip
handle-fd
mx
get-global
]
dip
{
{
+input+
[
add-input-callback
]
}
{
+output+
[
add-output-callback
]
}
}
case
"I/O"
suspend
[
io-timeout
]
when
]
if
;