Handling Multiple terminals


 
Thread Tools Search this Thread
Top Forums Programming Handling Multiple terminals
# 8  
Old 03-25-2010
Quote:
Originally Posted by dgre0018
I don't see the need for mutexing as the shared memory segment is being modified by only one process and read by only process also. Hence no corrupt data can occur.
Race conditions can still happen when the server is interrupted while writing to the shared mem. Until the server finishes, clients would view incompletely-updated data. If your data structure is just a "video buffer" this probably won't cause crashing, though you could get the ASCII equivalent of video tearing.

Might UNIX domain sockets work for you? They're not network sockets per-se, local-only, and designed for your problem(among others; things like syslog, mysql, and X11 also use them for local communication.) They're like beefed-up FIFOs. The server creates a special file, probably under /tmp/ or /var/run/, which clients connect to. Unlike fifo's, more than one client can connect simultaneously. The server checks for connections with the accept() system call like a network socket would. Once that succeeds there's a communication channel between the client and the server. The server would fork off a process to deal with this connection and close its own copy afterwards.

There's no easy way beyond this, really. That's what this is there for. If you want to do without you'll just be building your own private version of the same thing.
# 9  
Old 03-26-2010
UNIX Domain Sockets

Thanks for your help...very much appreciated...I'll try to learn some more about domain sockets as I'm not that familiar with the topic.

---------- Post updated at 04:38 AM ---------- Previous update was at 04:27 AM ----------

one last thing hehe....do u guys have any idea of how I can distribute the same screen among multiple terminals ? I am using ncurses and want to distribute the WINDOW structure to all the connected terminals.
# 10  
Old 03-26-2010
Quote:
Originally Posted by dgre0018
one last thing hehe....do u guys have any idea of how I can distribute the same screen among multiple terminals ? I am using ncurses and want to distribute the WINDOW structure to all the connected terminals.
ncurses didn't work that way last time you asked, and continues to not work that way now. Each process will have to be responsible for its own drawing and nobody else's.

It's a variation of a fairly common question actually: "how do I write to 9 files with one fd?" You really can't. Yours is complicated by three layers of other problems though!

Last edited by Corona688; 03-26-2010 at 12:38 PM..
# 11  
Old 03-27-2010
re

do you think it's possible to have a process write the WINDOW to a file which multiple processes read from simultaneously ? I had tried to do this using shared memory by having the window kept in shared memory but each time I accessed the window from the child process I kept getting a segmentation fault. Any ideas ? Thanks for your help and patience btw..thank god for ppl like u!
# 12  
Old 03-29-2010
Quote:
Originally Posted by dgre0018
do you think it's possible to have a process write the WINDOW to a file which multiple processes read from simultaneously?
curses won't treat a file like a terminal and won't be fooled. Besides, whose to say all your clients will be using the same terminal? You need to let your clients do their own drawing.
Quote:
I had tried to do this using shared memory by having the window kept in shared memory but each time I accessed the window from the child process I kept getting a segmentation fault.
This is because, as stated twice previously, curses does not work that way. A WINDOW structure created in one process won't be valid in another. In fact any pointers and things containing pointers won't be valid when shared. Pointers point to memory local to its process, if they even point to any valid memory in a different process it will be a complete coincidence.

I think you're going to have to give up on sharing terminals with other processes and share data with them instead. Tell them what to draw but let them do their own drawing. (or just redraw everything every frame, and make it more efficient later.) You could keep an 80x25 character array in shared mem, and communicate to your clients what sections they need to redraw, or perhaps just when. I do think you'll need synchronization to accomplish this well.
# 13  
Old 03-30-2010
re:

If you have shared memory, why does the server need to handle the input?

The client process writes and reads shared memory. What else is needed?

fully agree with you.

Last edited by pludi; 03-30-2010 at 01:18 PM.. Reason: removed spam
# 14  
Old 03-30-2010
Quote:
Originally Posted by friendyomi
If you have shared memory, why does the server need to handle the input?

The client process writes and reads shared memory. What else is needed?
Reinventing inter-client communication with shared memory is essentially building your own pipes and sockets from scratch. Besides, he said he didn't want to do any synchronization.

Wait, you don't actually agree with him, you're a spammer advertising something.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using getopts for handling multiple options

Hi Guys, I have created a script for our automated DB creation, it works fine with default option(-d). $ ./test_db.ksh -d abc 11 dev -d is Default option ORACLE_SID=abc ORACLE_VERSION=11 ENV_TYPE=dev For creating a customized DB, i thought of giving the user different options.... (8 Replies)
Discussion started by: veeresh_15
8 Replies

2. Shell Programming and Scripting

Automate an application using scripting, managing multiple terminals

Hi I am new to Ubuntu and Bash scripting. I am working on a project to give a demo on an SDN application to my class. I need some help in scripting to create the demo. Please help in case if you have any idea on what am asking. The demo uses a tool called mininet. I need just one script so... (2 Replies)
Discussion started by: anzal
2 Replies

3. Shell Programming and Scripting

ISSUE in handling multiple same name files :-(

Dear all, My work is completely stuck cos of the following issue. Please find it here and kindly help me. Task is following: I have set of files with such pattern 1t-rw-rw-r-- 1 emily emily 119 Jun 11 10:45 vgtree_5_1_pfs.root 3t-rw-rw-r-- 1 emily emily 145 Jun 11 10:46 vgtree_5_3_pfs.root... (4 Replies)
Discussion started by: emily
4 Replies

4. Shell Programming and Scripting

Help with Handling multiple argument in shell script

Hi i have written a shell script that takes only single ip address from the user and calculates its latency and reliability, can you please tell me that what should be done if i want that user should enter 100 or 1000 ip address (5 Replies)
Discussion started by: Preeti_17
5 Replies

5. AIX

How to open multiple virtual terminals to a single LPAR

I just wondering if there are ways to open multiple virtual terminal to a single LPAR. After I have use putty to login to the VIOS. I will use mkvt -id <LPAR id> to open console but if my friend want to open 2 second one, it will say, VT already connected. IS there a way to work this around ? ... (1 Reply)
Discussion started by: wingcross
1 Replies

6. 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

7. Shell Programming and Scripting

calling multiple terminals

I'd like to write a script that will call n number of terminals that will all ssh to X-server and automatically enter the same password. Unfortunately I'm not exactly sure what kind of commands would work for me here because when I call for gnome-terminal, a new terminal pops up and the old... (1 Reply)
Discussion started by: gelitini
1 Replies

8. UNIX for Advanced & Expert Users

Multiple file handling

Dear All, I have two files, which looks like: File 1 124 235 152 178 156 142 178 163 159 File 2 124|5623 452|6698 178|9995 (8 Replies)
Discussion started by: rochitsharma
8 Replies

9. UNIX for Advanced & Expert Users

Multiple Terminals

Dear Members, I have aquired a load of old Wyse dumb terminals. I have a Linux system set up that I want to be the host for all of these. Now, I know these don't use cat5 or standard networking. They are all done through serial (com) ports. However, I researched this more and found a converter... (25 Replies)
Discussion started by: Phobos
25 Replies
Login or Register to Ask a Question