1

私はWindowsでCによって単純なシェルを構築しようとしています.私のプラットフォームは良くないので、検索して以下のようなコードから始めます:

shell_terminal = STDIN_FILENO;
shell_is_interactive = isatty (shell_terminal);
if (shell_is_interactive)
{
    /* Loop until we are in the foreground.  */
    while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
    kill (- shell_pgid, SIGTTIN);

    /* Ignore interactive and job-control signals.  */
    signal (SIGINT, SIG_IGN);
    signal (SIGQUIT, SIG_IGN);
    signal (SIGTSTP, SIG_IGN);
    signal (SIGTTIN, SIG_IGN);
    signal (SIGTTOU, SIG_IGN);
    signal (SIGCHLD, SIG_IGN);

    /* Put ourselves in our own process group.  */
    shell_pgid = getpid ();
    if (setpgid (shell_pgid, shell_pgid) < 0)
    {
    perror ("Couldn't put the shell in its own process group");
    exit (1);
    }

    /* Grab control of the terminal.  */
    tcsetpgrp (shell_terminal, shell_pgid);

    /* Save default terminal attributes for shell.  */
    tcgetattr (shell_terminal, &shell_tmodes);
}

しかし、いくつかのバグがありました:

[Error] 'tcgetpgrp' was not declared in this scope
[Error] 'getpgrp' was not declared in this scope
[Error] 'SIGTTIN' was not declared in this scope
[Error] 'kill' was not declared in this scope
...

私の環境に問題があるか、ライブラリが不足していると思います。私の問題は何ですか?ありがとう!

4

1 に答える 1