- #ifndef PTHREAD
- answerscripts_process_message((void *)conv);
- #else
- pthread_t t;
- puts("new thread...");
- pthread_create(&t, NULL, answerscripts_process_message, (void *)conv);
- puts("new thread created!");
+ //Export variables to environment
+ setenv(ENV_PREFIX "FROM", who, 1);
+ setenv(ENV_PREFIX "MSG", message, 1);
+ setenv(ENV_PREFIX "STATUS", status_id, 1);
+ setenv(ENV_PREFIX "STATUS_MSG", status_msg, 1);
+
+ //Launch job on background
+ answerscripts_job *job = (answerscripts_job*) malloc(sizeof(answerscripts_job));
+ job->pipe = popen(hook_script, "r");
+ job->conv = conv;
+
+ #ifndef __WIN32__
+ int fflags = fcntl(fileno(job->pipe), F_GETFL, 0);
+ fcntl(fileno(job->pipe), F_SETFL, fflags | O_NONBLOCK);