|
Home > Archive > Unix Programming > November 2006 > openpty() function
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
openpty() function
|
|
|
| Hello there,
I'm trying to program a little app where I need to input data into a
first terminal (the one I launch the process) and to ouput data into
another terminal. So I need to open a terminal during execution.
Aftersome searches, I got interested in openpty() function.
I read some examples and man-pages but something is not very clear in
my mind.
Does this function allow opening new terminal or what ?
Do I expect the right aim of this function ?
'Cause when I run my prog, nothing happens, so I wonder :S
Here the lines:
int master, slave;
if (openpty ( &master, &slave, NULL, NULL, NULL) < 0)
error("Error !!!");
Thanks a lot 
| |
|
| Your question is pretty vague. Have you already opened a terminal you
want to write to, or you want to "create" it at runtime? If the first
case is true, which terminal type do you use - terminal emulation like
"konsole" or "xterm" or the "regular" console tty1, tty2 etc. (the ones
you get by (CTRL-)ALT-F1, (CTRL)-ALT-F2 ...). If the second case is
true, then you need again to decide which ones of these you want to
use.
In either way, the easiest way is to supply the regular open() system
call by the filename of the terminal in the /dev/ directory.
The last thing, are you sure you want to write it just "to the
terminal"? Perhaps you want another program to run at another terminal,
which will then display the results. If so (which I advise), then you
need some form of simple interprocess communication, probably by using
pipe() system call or some fifo file.
References:
Man pages ;-)
PaowZ wrote:
> Hello there,
>
> I'm trying to program a little app where I need to input data into a
> first terminal (the one I launch the process) and to ouput data into
> another terminal. So I need to open a terminal during execution.
> Aftersome searches, I got interested in openpty() function.
> I read some examples and man-pages but something is not very clear in
> my mind.
> Does this function allow opening new terminal or what ?
> Do I expect the right aim of this function ?
> 'Cause when I run my prog, nothing happens, so I wonder :S
> Here the lines:
> int master, slave;
> if (openpty ( &master, &slave, NULL, NULL, NULL) < 0)
> error("Error !!!");
>
> Thanks a lot 
| |
|
| yep, in fact openpty() doesn't to be the function I need.
I need to open an xterm at run time in order to display output instead
of displaying it within the first xterm.
So, i need something like the code below:
FILE *lister;
if ((lister =3D popen("/usr/X11R6/bin/xterm -e more /dev/tty","w")) =3D=
=3D
NULL)
error("Error -cant pipe to new xterm");
else
{
fprintf(lister,"This is a test\n");
pclose(lister);
}
but the fact is that, I don't manage to output data and still searching
why.
regards.
Darko a =E9crit :
[vbcol=seagreen]
> Your question is pretty vague. Have you already opened a terminal you
> want to write to, or you want to "create" it at runtime? If the first
> case is true, which terminal type do you use - terminal emulation like
> "konsole" or "xterm" or the "regular" console tty1, tty2 etc. (the ones
> you get by (CTRL-)ALT-F1, (CTRL)-ALT-F2 ...). If the second case is
> true, then you need again to decide which ones of these you want to
> use.
>
> In either way, the easiest way is to supply the regular open() system
> call by the filename of the terminal in the /dev/ directory.
>
> The last thing, are you sure you want to write it just "to the
> terminal"? Perhaps you want another program to run at another terminal,
> which will then display the results. If so (which I advise), then you
> need some form of simple interprocess communication, probably by using
> pipe() system call or some fifo file.
>
> References:
> Man pages ;-)
>
> PaowZ wrote:
|
|
|
|
|