cominglately 2015-11-15 03:40 采纳率: 72.1%
浏览 771

linux 环境,tcgetsid(STDOUT_FILENO),返回error

linux 环境,tcgetsid(STDOUT_FILENO),返回error: Inappropriate ioctl for device
 实验,检测会话是否存在:    
        getsid(0),替换
       返回SID=29307
实验说明会话存在,那么tcgetsid( argumen 【?】),argument应该怎么填写呢?

    源码:

#include"apue.h"
int main()
{
pid_t pid;
if((pid=fork()) err_sys("fork error");
else if(pid!=0)
exit(0);
else
{
printf("waitting for parent leaving\n");
sleep(5);
pid_t pid,pgid,pid4,pid3,sid;
if((sid=setsid())==-1)
err_sys("sersid error");
pid=getpid();
pgid=getpgrp();
if(pid==pgid)
printf("The current process becomes the process group id :%ld\n",(long)pid);
if((sid=tcgetsid(STDIN_FILENO))==-1)
{
printf("EBADF=%d\t,ENOTTY=%d\n",EBADF,ENOTTY);
printf("errno:%d\n",errno);
err_sys("tcgetsid error");
}
/*#include
pid_t tcgetsid(int fd);
*return the session ID ,only when fd refers to the controlling terminal of our session.Otherwise -1 is returned,and errno is set appropriately.
/
printf("SID=%ld\n",(long)sid);
}
exit(0);
}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法