ForkPty without Fork

  • Follow


Hi all,

We are porting an RTOS app to Linux 2.6. We have implemented the TASKs
with real time pthreads and one of the tasks is responsible for a
terminal session. All of the calls to STDIN and STDOUT are posix
complaint, we have no problems there.

Our problem is that previous system is  using some non-standart
functions to set/get terminal buffer from a GSP(generic serial packet)
device. After investigating the issue for about a month, I concluded
that we can change this structure to standart pseudo-terminal
structure that we already have in Linux. I have done some tests with
forkpty() functions and it is working just as I wanted, but as the
name implies it is forkinf off another process. Currently, we have
only one application and under it we have dozens of TASKs(real time
threads). So, if we fork off another process, it seems to me that we
will lose our prioritization over our tasks and complicate our code
more. By the way, we only support one session means, only one person
can connect to our application at the same time either via telnet or
serial.

So is it possible to change the current running process's terminal to
a pseudo terminal without forking? I tried open_pty() and dup2() but
without success, any help on that?


Regards,
0
Reply sumerc (48) 2/20/2009 3:18:55 PM

On Feb 20, 11:18=A0pm, k3xji <sum...@gmail.com> wrote:
> Hi all,
>
> We are porting an RTOS app to Linux 2.6. We have implemented the TASKs
> with real time pthreads and one of the tasks is responsible for a
> terminal session. All of the calls to STDIN and STDOUT are posix
> complaint, we have no problems there.
>
> Our problem is that previous system is =A0using some non-standart
> functions to set/get terminal buffer from a GSP(generic serial packet)
> device. After investigating the issue for about a month, I concluded
> that we can change this structure to standart pseudo-terminal
> structure that we already have in Linux. I have done some tests with
> forkpty() functions and it is working just as I wanted, but as the
> name implies it is forkinf off another process. Currently, we have
> only one application and under it we have dozens of TASKs(real time
> threads). So, if we fork off another process, it seems to me that we
> will lose our prioritization over our tasks and complicate our code
> more. By the way, we only support one session means, only one person
> can connect to our application at the same time either via telnet or
> serial.
>
> So is it possible to change the current running process's terminal to
> a pseudo terminal without forking? I tried open_pty() and dup2() but
> without success, any help on that?

I think you may look at openvt, chvt, and if it is not enough, you can
check it's source code to see how it works.

---------------------------
Media File Security V1.0, make your private media files easily
secured. http://www.media-file-security.com

0
Reply binary.chen (324) 2/21/2009 1:50:58 AM


k3xji wrote:
> So is it possible to change the current running process's terminal to
> a pseudo terminal without forking? I tried open_pty() and dup2() but
> without success, any help on that?

You mean you want to change the controlling terminal of the current 
process? Then I think openpty() and login_tty() should do the trick. 
Calling forkpty() is like calling openpty(), then fork(), then login_tty().

What is it you want on the master end of the pty?


Bjarni
-- 

                        INFORMATION WANTS TO BE FREE
0
Reply bjarni (115) 2/21/2009 8:28:34 AM

Bin Chen wrote:
>> So is it possible to change the current running process's terminal to
>> a pseudo terminal without forking? I tried open_pty() and dup2() but
>> without success, any help on that?
> 
> I think you may look at openvt, chvt, and if it is not enough, you can
> check it's source code to see how it works.

You appear to be confusing pseudo terminals and virtual terminals.


Bjarni
-- 

                        INFORMATION WANTS TO BE FREE
0
Reply bjarni (115) 2/21/2009 8:32:50 AM

3 Replies
72 Views

(page loaded in 0.255 seconds)

Similiar Articles:




7/24/2012 2:24:50 AM


Reply: