文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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;
}
相关阅读 更多 +
排行榜 更多 +
萌趣贪吃蛇

萌趣贪吃蛇

休闲益智 下载
粘液快跑

粘液快跑

休闲益智 下载
一个不能跑

一个不能跑

休闲益智 下载