Skip to content

Instantly share code, notes, and snippets.

@abhijitiitr
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijitiitr/9ceba0b519334789dfd6 to your computer and use it in GitHub Desktop.
Save abhijitiitr/9ceba0b519334789dfd6 to your computer and use it in GitHub Desktop.
/* niftest.c */
#include "erl_nif.h"
#include <unistd.h>
#include <stdio.h>
static ERL_NIF_TERM hello(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
int pid;
enif_get_int(env, argv[0], &pid);
if (pid==10 || pid==7 || pid == 1)
{
printf("%s\n", "Sleeping");
usleep(100);
}
printf("From %d\n\r",pid);
return enif_make_string(env, "Hello world!", ERL_NIF_LATIN1);
}
static ErlNifFunc nif_funcs[] =
{
{"hello", 1, hello}
};
ERL_NIF_INIT(niftest,nif_funcs,NULL,NULL,NULL,NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment