Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

64. Pseudoterminals > Connecting Processes with a Pseudoterminal: ptyFork()

Connecting Processes with a Pseudoterminal: ptyFork()

We are now ready to implement a function that does all of the work of setting up a connection between two processes using a pseudoterminal pair, as shown in Figure 64-2. The ptyFork() function creates a child process that is connected to the parent by a pseudoterminal pair.

#include "pty_fork.h"

pid_t ptyFork(int *masterFd, char *slaveName, size_t snLen,
            const struct termios *slaveTermios, const struct winsize *slaveWS);

Note

In parent: returns process ID of child on success, or -1 on error; in successfully created child: always returns 0

The implementation of ptyFork() is shown in Example 64-2. This function performs the following steps:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint