[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

A simple program behaves differently under mc's terminal and a "normal" terminal ?



Package: mc
Version: 4.5.1-1.1

I tried to run a simple program with mc's terminal (ctrl+o from mc) and a 
"normal" terminal and got different results.
Is this expected ?

When running under a normal terminal the program (pipe1) produces:

[11:59:17 sigi]$ ./pipe1
[12:02:47 sigi]$ hello world

But with mc's terminal I do not get its output:

[13:48:37 sigi]$ ./pipe1 
[14:01:55 sigi]$ 

It is worth saying that the output is created by a child process.

The code of pipe1, which is mostly taken from a book, is:

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

#define MAXLINE 80

int main(void)
{
  int	n, fd[2];
  pid_t	pid;
  char	line[MAXLINE];
  
  if (pipe(fd) < 0)
    fprintf(stderr, "pipe error");

  if ( (pid = fork()) < 0)
    fprintf(stderr, "fork error");

  else if (pid > 0) {		/* parent */
    close(fd[0]);
    write(fd[1], "hello world\n", 12);
    
  } else {			/* child */
    close(fd[1]);
    n = read(fd[0], line, MAXLINE);
    write(STDOUT_FILENO, line, n);
  }
  
  exit(0);
}


-- System Information
Debian Release: 2.1
Kernel Version: Linux rakefet 2.0.36 #2 Sun Feb 21 15:55:27 EST 1999 i586 
unknow
n

Versions of the packages mc depends on:
ii  libc6           2.0.7.19981211 GNU C Library: shared libraries
ii  libgpmg1        1.14-3         General Purpose Mouse Library [libc6]
ii  libncurses4     4.2-3          Shared libraries for terminal handling
ii  e2fsprogs       1.12-4         The EXT2 file system utilities and libraries
        ^^^ (Provides virtual package libcomerr2)
ii  e2fsprogs       1.12-4         The EXT2 file system utilities and libraries
        ^^^ (Provides virtual package libext2fs2)



Reply to: