Sponsored Content
Full Discussion: fork multiple shells
Top Forums Programming fork multiple shells Post 302191120 by ramen_noodle on Thursday 1st of May 2008 03:05:21 PM
Old 05-01-2008
That's not going to be a terrifically useful enterprise without giving the shells the environment they expect. See man forkpty if on linux/*BSD.
Also you could handle child exits asynchronously by using waitpid in a handler for SIGCHLD and avoid your zombie woes.
An example: rmathew: Terminal Sickness

HTH
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Shells

I have came across the definitions of these shells korn bourne c etc .. but honestly till now i din't get the exact difference between these threes , the advantages ..... can anyone pinpoint me where it actually lies ..... don;t include me answers like aliasing in c is posible and not in bourne ..... (3 Replies)
Discussion started by: dino_leix
3 Replies

2. UNIX for Dummies Questions & Answers

How to open multiple shells while the scripts keeps running.

Hello, I've tried for a while now to run a bash script that continues to the end, while opening new shells as needed. I've tried xterm -e "somecommand"; & xterm -e " somecommand"; I've also tried screen -S "somecommand"; & screen -S "somecommand"; All without any luck, they... (5 Replies)
Discussion started by: Closed_Socket
5 Replies

3. Programming

Multiple process using fork()

I have a code which has four different process, each printing different message. I have provided it with user input (implemented using thread), depending on which the corresponding message from that process has to be printed.The code is shown below.when I run the pgm, it takes input such as... (1 Reply)
Discussion started by: shashi
1 Replies

4. Shell Programming and Scripting

running Multiple terminals/shells

Hi, I'm looking for a way to send commands through multiple shells/terminals (not sure which is proper syntax). Basically, I have to open 3 different shells/terminals and run separate parts of a program suite in each of them. I find this annoying. The commands I have to do are simple, and could... (1 Reply)
Discussion started by: Caradoc
1 Replies

5. Programming

Need help with fork, forking multiple childs and shared memory

Hi all, I m writing an application, where i need to fork multiple childs and those child should handle particular task given to them. More descriptive. For example, suppose i have 4 Network, each network has multiple nodes. Now on the basis of network child should be forked and these child... (8 Replies)
Discussion started by: helpmeforlinux
8 Replies

6. Programming

multiple fork() question

I writing a program that forks three times but only on the parent process. The three children processes then produces output in order. 1, 2, 3. I am confused on how to do this. I have tried multiple if and else if statements but the output does not come out right. How should I go about doing this? (1 Reply)
Discussion started by: TWhitt24
1 Replies

7. UNIX for Dummies Questions & Answers

Shells

Lets say my default shell is bash and then i load up csh and then ksh. How would i exit csh without exiting ksh? so basically i gone from bash > csh > ksh and i wish to close csh (2 Replies)
Discussion started by: Bill Thompson
2 Replies

8. UNIX for Dummies Questions & Answers

Please what are shells?

I mean like this: http://shells.red-pill.eu/ Can anyone explain how this works? I hope my post is not spam. I think its related to linux. Thank you (1 Reply)
Discussion started by: postcd
1 Replies

9. Shell Programming and Scripting

How to call exeute multiple bash shells from one master shell?

I have few bash shells, which i want to run sequentially, how to create a shell file, and execute/call one after other shell file. I am very new to shell programming. Bult some and running individually and also with crontab scheduler. never had a shell calling other shells, kindly would like... (2 Replies)
Discussion started by: cplusplus1
2 Replies

10. UNIX for Beginners Questions & Answers

One parent, multiple children pipe with fork()

The task I have to do is something along the lines "I receive some input and based on the first character I send it through pipe to one of the children to print". The scheme it is based on is 1->2; 1->3; 1->4; 2 will print all the input that starts with a letter, 3 will print all the input that... (2 Replies)
Discussion started by: Ildiko
2 Replies
openpty(3)						     Library Functions Manual							openpty(3)

NAME
openpty, forkpty - Open and fork pseudoterminals LIBRARY
Standard C Library (libc.a) SYNOPSIS
#include <sys/termios.h> <sys/ioctl.h> int openpty( int *master, int *slave, char *name, struct termios *termp, struct winsize *winp); pid_t forkpty( int *master, char *name, struct termios *termp, struct winsize *winp); PARAMETERS
Points to the returned file descriptor for the master pseudoterminal (pty). Points to the returned file descriptor for the slave pty. Points to the pathname of the slave pty. This parameter is optional. Specifies the termios structure containing the terminal attributes for the opened slave pty. This parameter is optional. Specifies the winsize structure containing the window attributes for the opened slave pty. This parameter is optional. DESCRIPTION
The openpty() function opens the pty master/slave pair and sets the terminal attributes of the slave pseudoterminal according to the speci- fications in the termp and winp parameters. The forkpty() function creates a child process and establishes the slave pty as the child process' controlling terminal. The openpty() function will first attempt to open an SVR4 slave device, such as /dev/pts/11. If unsuccess- ful, it will attempt a BSD device, such as /dev/ttyp1. Note If a signal handler for SIGCHLD exists and the openpty() or forkpty() function is invoked without superuser privileges, the signal handler must be able to dismiss an unexpected SIGCHLD signal. RETURN VALUES
Upon successful completion, the openpty() function returns a value of 0 (zero). Otherwise, it returns a value of -1. On success, the forkpty() function returns a value of 0 (zero) to the child process and returns the process ID of the child process to the parent process. On error, the forkpty() function returns a value of -1 to the parent process and does not create a child process. ERRORS
If any of the following conditions occurs, the openpty() function sets errno to the corresponding value: The slave pty special files have been exhausted. No more ptys can be opened. The configured number of ptys has been reached. The system limit for open file descriptors per process has already reached OPEN_MAX. The system limit for open file descriptors has been reached. [Tru64 UNIX] Either the OPEN_MAX value or the per-process soft descriptor limit is checked. The system file table is full. The system was unable to allocate kernel memory for more file descriptors/processes. The system-imposed limit on the total number of processes executing for a single user has been exceeded. This limit can be exceeded by a process with superuser privilege. RELATED INFORMATION
Functions: fork(2) delim off openpty(3)
All times are GMT -4. The time now is 02:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy