The C equivalent would be:
open("atomic.file", O_RDWR|O_CREAT|O_EXCL, 0644);
PicoLisp:
# The flags can be read from sysdefs, but here we define them manually (Linux)
(setq
O_RDWR 2 #(in '("@src64/sysdefs") (from "O_RDWR") (read))
O_CREAT 64 #(in '("@src64/sysdefs") (from "O_CREAT") (read))
O_EXCL 128 #(in '("@src64/sysdefs") (from "O_EXCL") (read))
)
# The file mode 0644 is octal and must be converted to int
(native "@" "open" 'I "atomic.file" (| O_RDWR O_CREAT O_EXCL) (oct "0644"))
# -> 3
(native "@" "open" 'I "atomic.file" (| O_RDWR O_CREAT O_EXCL) (oct "0644"))
# -> -1
First call is successful (3), second call fails (-1), as expected.