On 28/10/2010, at 9:12 AM, john skaller wrote:

> 
> I guess I use open() then dup2() to create fd's for 0,1,2 so 
> the webserver can still do I/O.. not sure what happens
> to C++ streams cin, cout, cerr or C streams stdin, stdout. stderr
> though (I presume they will just keep working since underneath
> they have to use the unix fds ..?)


well, that's interesting. I do:

 int sout = open("mystdout.log",O_CREAT | O_WRONLY | O_TRUNC);
  int serr = open("mystderr.log",O_CREAT | O_WRONLY | O_TRUNC);
  close(0); close(1); close(2);
  dup2(sout,1);
  dup2(serr,2);
  while(1){
  FILE *f= fopen("log.log","w");
  fprintf(f,"Daemon running\n");
  fclose(f);
  printf("[stdout]Daemon running pid=%d\n",getpid());
  fprintf(stderr,"[stderr]Daemon running pid=%d\n",getpid());
  sleep(5);
  }

and all the output goes into mystdout.log, mystderr.log is
empty.  what did I do wrong here?

--
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