Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Nov 27, 2023
2 parents 8702e6e + b51f3e6 commit 3368e07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ Non-standard predicates
posix_ctime/2 # posix_time(+seconds,-atom)
posix_time/1 # posix_time(-seconds)
posix_getpid/1 # posix_pid(-pid)
posix_getppid/1 # posix_ppid(-pid)
posix_fork/1 # posix_fork(-pid)

nb_setval(K,V)
Expand Down
13 changes: 13 additions & 0 deletions src/bif_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ static bool bif_posix_getpid_1(query *q)
return unify(q, p1, p1_ctx, &tmp, q->st.curr_frame);
}

static bool bif_posix_getppid_1(query *q)
{
GET_FIRST_ARG(p1,var);
cell tmp;
#ifndef __wasi__
make_int(&tmp, getppid());
#else
make_int(&tmp, -1);
#endif
return unify(q, p1, p1_ctx, &tmp, q->st.curr_frame);
}

static bool bif_posix_fork_1(query *q)
{
GET_FIRST_ARG(p1,var);
Expand All @@ -256,6 +268,7 @@ builtins g_posix_bifs[] =
{"posix_ctime", 2, bif_posix_ctime_2, "+integer,-atom", false, false, BLAH},
{"posix_time", 1, bif_posix_time_1, "-integer", false, false, BLAH},

{"posix_getppid", 1, bif_posix_getppid_1, "-integer", false, false, BLAH},
{"posix_getpid", 1, bif_posix_getpid_1, "-integer", false, false, BLAH},
{"posix_fork", 1, bif_posix_fork_1, "-integer", false, false, BLAH},

Expand Down

0 comments on commit 3368e07

Please sign in to comment.