VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/share/emscripten/tests/unistd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/emscripten/tests/unistd/ttyname.c
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main() {
  int err;
  int stdin, null, dev;
  char buffer[256];
  char* result;

  stdin = open("/dev/stdin", O_RDONLY);
  null = open("/dev/null", O_RDONLY);
  dev = open("/dev", O_RDONLY);

  result = ctermid(buffer);
  assert(!strcmp(result, "/dev/tty"));

  // strstr instead of strcmp as native code may
  // be using a virtual console (e.g. /dev/tty02)
  err = ttyname_r(stdin, buffer, 256);
  assert(!err);
  assert(strstr(buffer, "/dev/tty"));

  err = ttyname_r(stdin, buffer, 2);
  assert(err == ERANGE);

  result = ttyname(stdin);
  assert(strstr(result, "/dev/tty"));

  result = ttyname(null);
  assert(!result);

  result = ttyname(dev);
  assert(!result);

  puts("success");

  return EXIT_SUCCESS;
}

VaKeR 2022