Sponsored Content
The Lounge What is on Your Mind? Speculative Shell Feature Brainstorming Post 302509805 by Corona688 on Thursday 31st of March 2011 07:01:20 PM
Old 03-31-2011
Quote:
Originally Posted by tetsujin
"expect" shouldn't be needed.
I meant screen, sorry. Probably doesn't change the answer though.
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?
Quote:
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.
Sure, if given access to them. Just something to keep in mind.
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. Builtins could be run in threads, so wouldn't need a separate context.

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.

Some builtins, like echo, might not need any context. When you know the amount of text is smaller than the size of your pipe, you know it'll never block -- so just cram the text in the write-end and close the write-end in advance. You don't need a new thread just to do that.
Quote:
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...
Why not let the mutexes do the blocking?
Quote:
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.
Reference, please? Things I've seen suggest quite differently. Then again, that's something I saw inside the linux pthreads library, so that might be things they had to do to prevent threads being cloned rather than things I'd have to do...

If true, that would make it a ton easier.

Last edited by Corona688; 03-31-2011 at 08:15 PM..
 

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