On 28/10/2010, at 1:33 PM, James Dennett wrote:

> 
> At this point my Felix-ignorance kicks in, and I don't have a clue
> what's going on.


It's quite simple: Felix main thread spawns a second thread which
reads the event queue (epoll, kqueue, etc) and does asynchronous
I/O on sockets according to the notifications (this only happens if you use
async I/O)

I seem to have fixed it by writing a trivial C program which make itself
a daemon then runs the Felix program (or any other program) by calling
execv():

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>

int main(int argc, char * const argv[]) {
  int child;
  printf("Running\n");
  if ((child=fork()) != 0) { printf("Forked %d\n",child); exit(0); }
  setsid();
  if ((child=fork()) != 0) { exit(0); }
  int sout = open("mystdout.log",O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | 
S_IWUSR | S_IRGRP | S_IROTH);
  int serr = open("mystderr.log",O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | 
S_IWUSR | S_IRGRP | S_IROTH);
  close(0); close(1); close(2);
  dup2(sout,1);
  dup2(serr,2);
  execv(argv[1], argv+1);
  printf("Exec failed\n");
}

A bit crude but it seems to work :)

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to