Sponsored Content
The Lounge What is on Your Mind? Speculative Shell Feature Brainstorming Post 302514495 by tetsujin on Saturday 16th of April 2011 03:04:59 AM
Old 04-16-2011
Quote:
Originally Posted by Corona688
Quote:
Probably the sensible default for this "TTY sharing" stuff is to simply not do the TTY sharing thing if there's no TTY.
But where would the output go instead?
Same place it would go to normally. Whatever the shell sees as FD #1.

Obviously if you're using stdout as some kind of formatted value stream, you don't want a bunch of processes writing data to it concurrently without some kind of synchronization: this is why I described a stdout sharing mechanism (separate from the /dev/tty sharing mechanism).

If somebody ran a multithreaded loop whose jobs produced newline-delimited value streams - that's a common enough formatting convention that it could just be built in to the shell. If those processes were writing out JSON or some XML schema, then it's something the user should probably be handling, by providing a program that takes those output streams and merges them into one.


Quote:
Quote:
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.
External commands have to be in a seperate context. There's just no other way to run them.
Yeah, mainly by "things" I meant builtins like variable assignment or "read". Things you would do to modify the environment, in cases where it's pretty reasonable for the user to expect that it'll modify the main shell's environment...

Quote:
Even if you fork(), it's possible to share memory by other means. Memory you've created with mmap() can be shared between such processes. So just being in a subshell doesn't mean you'd have to lose access to variables. Environment variables though come preallocated so can't be shared that way without torturing your process environment in cruel and unusual ways.
Hm, might have to think about that one. Of course you could get around it by simply copying all the env. variables to the shell's process memory and operating on those copies of the variables - a bit wasteful but a pretty simple dodge...

Quote:
Why not let the mutexes do the blocking?
Because I'm not talking about cases where threaded built-ins are blocking on some shared resource, I'm talking about them blocking on I/O, probably to a pipe as part of a larger job...

APUE chapter 12.9 explains the situation with pthreads and fork():
"Inside the child process, only one thread exists"
Of course I would be willing to bet there are some platforms or versions of platforms that got that wrong... APUE provides some coverage of different implementations to show differences but it'd take more time to tell you if it lists any for fork() in pthreads... Smilie
 

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 10:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy