23 lines
475 B
C
23 lines
475 B
C
|
#include <sys/mman.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
#include <skalibs/strerr2.h>
|
||
|
#include <skalibs/env.h>
|
||
|
#include <skalibs/exec.h>
|
||
|
|
||
|
#define USAGE "fdcreate name prog..."
|
||
|
|
||
|
int main(int argc, char const *const *argv) {
|
||
|
PROG = "fdcreate";
|
||
|
|
||
|
if (argc < 3) strerr_dieusage(100, USAGE);
|
||
|
int fd = memfd_create(argv[1], 0);
|
||
|
if (fd < 0) strerr_diefu1sys(111, "memfd_create");
|
||
|
char fd_str[10];
|
||
|
sprintf(fd_str, "%d", fd);
|
||
|
setenv(argv[1], fd_str, 1);
|
||
|
|
||
|
xexec(argv+2);
|
||
|
}
|