feat: remove stdio #2

Merged
ptrcnull merged 1 commit from :stdio-hell into master 2022-08-12 15:14:24 +00:00

View file

@ -1,7 +1,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <skalibs/types.h>
#include <skalibs/strerr2.h> #include <skalibs/strerr2.h>
#include <skalibs/env.h> #include <skalibs/env.h>
#include <skalibs/exec.h> #include <skalibs/exec.h>
@ -10,12 +10,14 @@
int main(int argc, char const *const *argv) { int main(int argc, char const *const *argv) {
PROG = "fdcreate"; PROG = "fdcreate";
char fd_str[10];
if (argc < 3) strerr_dieusage(100, USAGE); if (argc < 3) strerr_dieusage(100, USAGE);
int fd = memfd_create(argv[1], 0); int fd = memfd_create(argv[1], 0);
if (fd < 0) strerr_diefu1sys(111, "memfd_create"); if (fd < 0) strerr_diefu1sys(111, "memfd_create");
char fd_str[10];
sprintf(fd_str, "%d", fd); int_fmt(fd_str, fd);
setenv(argv[1], fd_str, 1); setenv(argv[1], fd_str, 1);
xexec(argv+2); xexec(argv+2);