Sponsored Content
The Lounge What is on Your Mind? Speculative Shell Feature Brainstorming Post 302509519 by tetsujin on Thursday 31st of March 2011 02:01:59 AM
Old 03-31-2011
Quote:
Originally Posted by Corona688
Quote:
In the design I've suggested here, the shell doesn't take responsibility for fixing that. (TTY sharing in a loop) Rather, it merely provides a mechanism that allows an external program to fix that...
Does that have to be done as part of the parallel loop? That sounds like something you might want to do in general, inside or outside a loop.
I'd considered that: the multiplexing/TTY sharing stuff would be useful outside the context of loops (or, if you prefer, at least as useful as it is in the context of loops. Smilie ) so addressing it as a general mechanism rather than something specific to loops would have advantages, make the shell language more orthogonal, etc.

One approach to doing this would be to have a separate step in which the PTYs and/or pipes are created to serve as /dev/tty, stdout, stdin for various jobs that are going to be run asynchronously: the file descriptors for these could be stored in array variables and passed to the loop construct, which would then pass them on to individual loop steps. Then probably one could come up with other cases where those FD arrays could be useful...

Quote:
You end up with shell scripts that require expect to run, and start spewing garbage to stdout if you try to disentangle them.
"expect" shouldn't be needed. Probably the sensible default for this "TTY sharing" stuff is to simply not do the TTY sharing thing if there's no TTY. ('course, there would be exceptions - cases where you might want TTY sharing to do its thing even if there's no TTY... If you're displaying the TTYs with xterms, for instance.)

Quote:
Utilities like ssh and su require password input to be from a terminal, but PTY's count. Something that gives you quick and easy access to PTY's, let alone in a high-performance parallel manner, isn't the sort of tool you want to just leave lying around
Hm, so is the problem just that people could use this capability to spoof input to programs that interact on /dev/tty?

I can live with that. Anyone who wants to do damage with that kind of capability can do it regardless of whether the shell serves up the functionality or they have to write their own program for it.

Quote:
Quote:
(Interpreted languages can implement threading without threads)
That's just timesharing. If you want actual benefits from threading, you must do multithreading and/or multiprocessing.
Well, yeah, but my aim with "shell threading" is mostly just to keep things from getting booted into a "subshell context" simply because they're occupying a particular position in the command. But I'm starting to feel like it's probably not the best way to go. It'd mean keeping track of all the "threads" that are blocking on something, maybe stuffing all that into a big select() call...

Actually, though (I had to look this up) - it turns out when you fork() in a (Posix) threaded app, the new process has just one thread initially. The threads aren't cloned. So there'd be a little care necessary to make sure the environment's in a usable state prior to calling fork() but otherwise using Posix threads shouldn't be a problem.
 

4 More Discussions You Might Find Interesting

1. SCO

BASH-like feature. is possible ?

Greetings... i was wondering if there is any shell configuration or third party application that enables the command history by pressing keyboard up arrow, like GNU/BASH does or are there an SCO compatible bash versio to download? where ? just wondering (sory my stinky english) (2 Replies)
Discussion started by: nEuRoMaNcEr
2 Replies

2. Shell Programming and Scripting

Creating a command history feature in a simple UNIX shell using C

I'm trying to write a history feature to a very simple UNIX shell that will list the last 10 commands used when control-c is pressed. A user can then run a previous command by typing r x, where x is the first letter of the command. I'm having quite a bit of trouble figuring out what I need to do, I... (2 Replies)
Discussion started by: -=Cn=-
2 Replies

3. UNIX for Dummies Questions & Answers

brainstorming automated response

I am managing a database of files for which there is a drop-box and multiple users. what i would like to do is set a criteria for files coming into the drop-box based on file structure. (they must be like this W*/image/W*-1234/0-999.tif) If the files do not match the criteria i want them to be... (1 Reply)
Discussion started by: Movomito
1 Replies

4. UNIX for Beginners Questions & Answers

Can we create any check-point feature in shell ?

I have a script as below and say its failed @ function fs_ck {} then it should exit and next time i execute it it should start from fs_ck {} only Please advise #!/bin/bash logging {} fs_ck {} bkp {} dply {} ## main function### echo Sstarting script echo '####' logging fs_ck... (3 Replies)
Discussion started by: abhaydas
3 Replies
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy