文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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;
}
相关阅读 更多 +
排行榜 更多 +
像素太空杀

像素太空杀

飞行射击 下载
忍者手势

忍者手势

飞行射击 下载
勇士X地下城大冒险

勇士X地下城大冒险

角色扮演 下载