использование псевдотерминала C

Я создал pThread с определенным номером сеанса. Если порождается pThread, я пытаюсь запустить другой процесс, запускающий псевдотерминал, используя openpty.

Вот некоторая часть кода:

if (openpty(&(numa_pst[session][0]),&(numa_pst[session][1]), NULL, NULL, NULL) != 0)
{
  int err_code = errno;
  sprintf (line_temp, "*** ERROR: numa openpty failed with:\n%s\n", strerror(err_code));
 }
session = 0;
int* pi = calloc(sizeof(int), 1);
*pi = session;
if (pthread_create(&system_wideThread[session], 0, system_wider, (void*)pi))
{
  int err_code = errno;
  sprintf (line_temp, "*** ERROR: System-wide thread spawn failed with:\n%s\n", strerror(err_code));
  return 0;
}

iResult = vfork();

else if (iResult == 0)
{
  close (numa_pst[session][0]);
  close(1); dup(numa_pst[session][1]) ;
sprintf(line, "./perf stat -a -e instructions -e cache-misses -e cache-references -e L1-dcache-loads -e L1-dcache-load-misses -e L1-dcache-stores -e L1-dcache-store-misses -e L1-dcache-prefetch-misses -e bus-cycles -I %i", PROFILING_TIMER);


  sprintf (line_temp, "%s\n", line);

  char *cmd[] = {"sh", "-c", line, NULL};
  printf("i'm here!");
  if (execvp("sh", cmd) < 0){
    int err_code = errno;
    sprintf (line_temp, "*** ERROR: exec failed for system-wide perf with:\n%s\n", strerror(err_code));

  }
 printf("i can't come here, why!?");
}

Однако данные по-прежнему печатаются в терминале, а не в псевдотерминале.

Любая идея, что происходит не так?

Вот еще информация:

GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from bg-service/papcmp...done.
(gdb) run perf foobar.txt once
Starting program: ./papcmp perf foobar.txt once
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6db5700 (LWP 24948)]

Тема создана! но не используется, почему?


person pistal    schedule 10.06.2014    source источник
comment
Perf также выдает вывод в виде stdout, а не stderr. Будет ли это иметь значение?   -  person pistal    schedule 10.06.2014
comment
Этот вопрос будет вознагражден, так как я застрял с ним на некоторое время.   -  person pistal    schedule 10.06.2014