Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Mar 2002 22:43:21 +0400 (MSD)
From:      Dmitry Mottl <dima@sinp.msu.ru>
To:        freebsd-questions@FreeBSD.org
Subject:   ioctl question
Message-ID:  <Pine.BSF.4.43.0203312238490.27126-100000@BigKing.sinp.msu.ru>

next in thread | raw e-mail | index | archive | help
Hi!

I have 'Operation not permitted' when I try to get a controlling terminal
via ioctl call

#include <sys/types.h>
#include <sys/ioctl.h>
#include <libutil.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char **argv, char **envp) {
	        int amaster, aslave;
	        char ttyname[25];
	        if(openpty(&amaster,&aslave,ttyname,NULL,NULL)) {
	                perror("Can't open pty");
	                exit(-1);
	        }
	        if (ioctl(aslave, TIOCSCTTY)==-1) { /* here I got error */
	                perror("Can't make controlling terminal");
	                exit(-1);
	        }
	        close(0);
	        close(1);
	        close(2);
	        dup(aslave);
	        dup(aslave);
	        dup(aslave);
	        execve(argv[1], argv+1, envp);
}

Thank You!



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.43.0203312238490.27126-100000>