1

I have a child using dup2:

    case OPGAME:
     users[userid]->userNextEntry = redirectuser( userid, 0, USERMODULES[MENU] );
     pid = fork();
     if ( pid == -1 )
      parseerror( SYSTEMERROR );
     users[userid]->userChildPID = pid;
     if ( pid == 0 ) { // child
      dup2( users[userid]->userFD, STDIN_FILENO );
      dup2( users[userid]->userFD, STDOUT_FILENO );
      dup2( users[userid]->userFD, STDERR_FILENO );
      execl( GAMEPLAYER, GAMEPLAYER, game, (char *)NULL );
     }
    break;

This directs a TCP/IP fd to the first 3 file descriptors, it's used to launch a game over telnet.

All is well with the code, runs as it should on every Linux distro I've tried, except when compiled with OpenBSD/NETBSD.

There, the new STDIN_FILENO receives a constant new line, or a FD_ISSET internal call.

I tried resetting STDIN to canonical input, no help. I believe that the child doesn't inherit changed termios options anyway (parent has done some changes).

Any idea would be helpful.

sawdust
  • 16,103
  • 3
  • 40
  • 50
  • 2
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – user16217248 Jun 17 '23 at 23:57
  • "*the new STDIN_FILENO receives a constant new line, or a FD_ISSET internal call*" -- Your summation is vague, and you don't provide a minimal, reproducible example. "*I believe ...*" -- So you're going to blindly "*believe*" rather that actually test your assumption?I believe I believe – sawdust Jun 18 '23 at 00:04
  • @sawdust you are making own assumptions about my use of language, applying your own measures isn't always correct – Giorgos Saridakis Jun 18 '23 at 08:47
  • @user16217248 The file descriptor is receiving new line ( ASCII 10 ) constantly in the redirected STDIN_FILENO, As it would if someone was hitting enter constantly in a non-dup2 STDIN – Giorgos Saridakis Jun 18 '23 at 08:52
  • for anyone interested-> telnet giorgos.website 8027 – Giorgos Saridakis Jun 19 '23 at 09:52

0 Answers0