O_NOCTTY 禁止取得終端控制 無效?
小弟在   LINUX   上寫了程序   ,   依照 <unix高級環境編程>    一書所說   , 
 會話組長(session   leader)   若不指明   O_NOCTTY   則打開終端設備會取得控制終端   ;    
 反之   ,   若指明則就不取得控制終端.   
 但是程序上指明了依然無效還是取得控制終端   ,   因為我額外寫了 
 用子程序開啟果然非會話組長無法取得控制終端   ,   打開   tty12   時   ,    
 顯示    "no   job   control   in   the   Shell "   ,   表示控制終端取得失敗   ,    
 為何   O_NOCTTY   對會話組長無效   ?   
 代碼如下: 
 #include <sys/stat.h>  
 #include <unistd.h>  
 #include <stdio.h>  
 #include <sys/types.h>  
 #include <sys/stat.h>  
 #include <fcntl.h>  
 #include <stdlib.h>  
 int   main() 
 { 
             pid_t   pid=fork();    
             if(pid> 0) 
             exit(0); 
             if(pid <0) 
             printf( "first   fork   error\n "),exit(1); 
             if(setsid() <0)    
             printf( "sedsid()   error\n "),exit(1);                    
             umask(022);    
             close(0);    
             close(1);    
             close(2);                     
             int   _new=open( "/dev/tty12 ",O_RDWR|O_NOCTTY);      
                dup2(_new,0);   //重新指向   stdin 
                dup2(_new,1);   //重新指向   stdout 
                dup2(_new,2);   //重新指向   stderr 
             execl( "/bin/bash ", "bash ",(char*)0);                  
 } 
------解决方案--------------------bash会重新取得会话终端的