文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Linux & BSD 伪终端

Linux & BSD 伪终端

时间:2006-07-15  来源:nahuat

#include <stdio.h>
#include <pty.h>
#include <utmp.h>

int
main(void)
{
    int fdm, fds, n;
    char name[1024];

    openpty(&fdm, &fds, name, 0, 0);
    printf("tty: %s\n", name);
    if (fork() == 0)
    {
        close(1);
        dup(fds);
        close(fds);
        execlp("ls", "ls", "-hl", 0);
        exit(0);
    }
    close(fds);
    while ((n = read(fdm, name, sizeof(name))) > 0)
    {
        printf("\n>>%.*s", n, name);
    }

    return 0;
}
相关阅读 更多 +
排行榜 更多 +
拉力竞速2

拉力竞速2

体育竞技 下载
文字乱舞水浒

文字乱舞水浒

角色扮演 下载
蓝图公考

蓝图公考

学习教育 下载