Skip to content

Commit 9fef4d9

Browse files
committed
ADDED: library(unix): mkfifo/2
1 parent 99c04a5 commit 9fef4d9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

unix.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,22 @@ pl_environ(term_t l)
310310
return PL_unify_nil(t);
311311
}
312312

313+
static foreign_t
314+
pl_mkfifo(term_t Path, term_t Mode)
315+
{ char *pathname;
316+
mode_t mode;
317+
318+
if ( !PL_get_chars(Path, &pathname, CVT_ALL|BUF_MALLOC|REP_MB) )
319+
return FALSE;
320+
if ( !PL_get_integer(Mode, (int *)&mode) )
321+
return pl_error("mkfifo", 2, NULL, ERR_ARGTYPE, 1, Mode, "mode");
322+
if ( !mkfifo(pathname, mode) < 0 )
323+
return pl_error("mkfifo", 2, NULL, ERR_ERRNO, errno, "create", "fifo", Path);
324+
325+
PL_free(pathname);
326+
return TRUE;
327+
}
328+
313329

314330
/*******************************
315331
* DEAMON IO *
@@ -527,6 +543,7 @@ install_unix()
527543
PL_register_foreign("dup", 2, pl_dup, 0);
528544
PL_register_foreign("detach_IO", 1, pl_detach_IO, 0);
529545
PL_register_foreign("environ", 1, pl_environ, 0);
546+
PL_register_foreign("mkfifo", 2, pl_mkfifo, 0);
530547
#ifdef HAVE_PRCTL
531548
PL_register_foreign("prctl", 1, pl_prctl, 0);
532549
#endif

unix.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
dup/2, % +From, +To
4545
detach_IO/0,
4646
detach_IO/1, % +Stream
47-
environ/1 % -[Name=Value]
47+
environ/1, % -[Name=Value]
48+
mkfifo/2 % +Path, +Mode
4849
]).
4950

5051
/** <module> Unix specific operations

0 commit comments

Comments
 (0)