|
40 | 40 | #include <stdlib.h>
|
41 | 41 | #include <unistd.h>
|
42 | 42 | #include <sys/types.h>
|
| 43 | +#include <sys/stat.h> |
43 | 44 | #include <sys/wait.h>
|
44 | 45 | #include <fcntl.h>
|
45 | 46 | #include <assert.h>
|
@@ -310,6 +311,22 @@ pl_environ(term_t l)
|
310 | 311 | return PL_unify_nil(t);
|
311 | 312 | }
|
312 | 313 |
|
| 314 | +static foreign_t |
| 315 | +pl_mkfifo(term_t Path, term_t Mode) |
| 316 | +{ char *pathname; |
| 317 | + mode_t mode; |
| 318 | + |
| 319 | + if ( !PL_get_chars(Path, &pathname, CVT_ALL|BUF_MALLOC|REP_MB) ) |
| 320 | + return FALSE; |
| 321 | + if ( !PL_get_integer(Mode, (int *)&mode) ) |
| 322 | + return pl_error("mkfifo", 2, NULL, ERR_ARGTYPE, 1, Mode, "mode"); |
| 323 | + if ( !mkfifo(pathname, mode) < 0 ) |
| 324 | + return pl_error("mkfifo", 2, NULL, ERR_ERRNO, errno, "create", "fifo", Path); |
| 325 | + |
| 326 | + PL_free(pathname); |
| 327 | + return TRUE; |
| 328 | +} |
| 329 | + |
313 | 330 |
|
314 | 331 | /*******************************
|
315 | 332 | * DEAMON IO *
|
@@ -527,6 +544,7 @@ install_unix()
|
527 | 544 | PL_register_foreign("dup", 2, pl_dup, 0);
|
528 | 545 | PL_register_foreign("detach_IO", 1, pl_detach_IO, 0);
|
529 | 546 | PL_register_foreign("environ", 1, pl_environ, 0);
|
| 547 | + PL_register_foreign("mkfifo", 2, pl_mkfifo, 0); |
530 | 548 | #ifdef HAVE_PRCTL
|
531 | 549 | PL_register_foreign("prctl", 1, pl_prctl, 0);
|
532 | 550 | #endif
|
|
0 commit comments