Commit Graph

62 Commits

Author SHA1 Message Date
ridiculousfish
4899086b3c Big fat refactoring of how redirections work. In fish 1.x and 2.0.0, the redirections for a process were flattened into a big list associated with the job, so there was no way to tell which redirections applied to each process. Each process therefore got all the redirections associated with the job. See https://github.com/fish-shell/fish-shell/issues/877 for how this could manifest.
With this change, jobs only track their block-level redirections. Process level redirections are correctly associated with the process, and at exec time we stitch them together (block, pipe, and process redirects).

This fixes the weird issues where redirects bleed across pipelines (like #877), and also allows us to play with the order in which redirections are applied, since the final list is constructed right before it's needed.  This lets us put pipes after block level redirections but before process level redirections, so that a 2>&1-type redirection gets picked up after the pipe, i.e. it should fix https://github.com/fish-shell/fish-shell/issues/110

This is a significant change. The tests all pass. Cross your fingers.
2013-08-19 18:06:24 -07:00
ridiculousfish
e849beabba Initial work towards various IO cleanups with an eye to fixing https://github.com/fish-shell/fish-shell/issues/110 2013-08-19 18:06:24 -07:00
ridiculousfish
2da81b0ae7 Formatting and style updates 2013-05-05 02:33:17 -07:00
ridiculousfish
e1734468f5 Support for building with C++11 2013-04-09 14:07:19 -07:00
ridiculousfish
9f8fe3d5e3 Hopeful fix to avoid forking for certain builtins like echo when they have an input redirection only 2013-02-22 13:20:27 -08:00
Cheer Xiao
66a445f043 Make io_file_t members const 2013-02-11 22:05:47 -08:00
Cheer Xiao
6527a48897 Make io_fd_t members const, make close_fd bool 2013-02-11 22:05:47 -08:00
Cheer Xiao
3f9706a7f3 Make io_data_t::fd const
In exec(), pipe_{write,read} no longer get reused.
2013-02-11 22:05:47 -08:00
ridiculousfish
1879dc4b59 Initial set of changes working to make fish robust against running out of file descriptors 2013-01-30 02:22:38 -08:00
Cheer Xiao
274f018494 Remove trailing whitespaces 2013-01-21 10:34:18 +08:00
ridiculousfish
98a17f4046 Remove some functions which were rendered trivial by xiaq's changes. Make io_file_t take its path directly. Make io_buffer_t no longer use a shared_ptr for its data. 2013-01-19 10:59:43 -08:00
Cheer Xiao
e0c858478a Revert "Make io_buffer_t::out_buffer a raw pointer, initialize in io_buffer_t's constructor"
This reverts commit d48ffab9d67da48cf45c2f5560c21a767144545f.

Conflicts:
	io.cpp
	io.h
2013-01-17 15:55:06 +08:00
Cheer Xiao
a3b15b995e Make io_data_t::io_mode const
A protected constructor is needed in io_pipe_t to let io_buffer_t override
its io_mode.
2013-01-17 15:55:06 +08:00
Cheer Xiao
57ef5289fe Make is_input a member of io_pipe_t 2013-01-17 15:55:06 +08:00
Cheer Xiao
a63c0311bb Make io_buffer_t::out_buffer a raw pointer, initialize in io_buffer_t's constructor 2013-01-17 15:55:05 +08:00
Cheer Xiao
9808829ece Make io_data_t pure virtual, its constructor protected 2013-01-17 15:55:05 +08:00
Cheer Xiao
00b6431ad9 Split out io_pipe_t, let io_buffer_t inherit it 2013-01-17 15:55:05 +08:00
Cheer Xiao
e020ad0c06 Convert io_buffer_read to io_buffer_t::read 2013-01-17 15:55:05 +08:00
Cheer Xiao
df0c1eb32c Add missing virtual qualifier to ~io_buffer_t 2013-01-17 15:55:05 +08:00
Cheer Xiao
9057801c4b Convert io_buffer_create to static io_buffer_t::create, make io_buffer_t constructor private 2013-01-17 15:55:05 +08:00
Cheer Xiao
0f443ef37b Convert io_buffer_destroy to ~io_buffer_t 2013-01-17 15:55:05 +08:00
Cheer Xiao
a20e0b9e2e Split out io_buffer_t, make input_redirect in exec() a raw pointer 2013-01-17 15:55:05 +08:00
Cheer Xiao
4b6bd7cae5 Split out io_file_t 2013-01-17 15:55:05 +08:00
Cheer Xiao
6f35792c74 Split out io_fd_t 2013-01-17 14:58:53 +08:00
Cheer Xiao
f1b375b042 Split out io_close_t 2013-01-17 14:58:53 +08:00
Cheer Xiao
165068c81d Put io_data_t detail printing in virtual io_data_t::print 2013-01-17 14:58:53 +08:00
Cheer Xiao
89993e9cbf Let io_data_t constructor take optional io_mode and fd 2013-01-17 14:58:52 +08:00
Cheer Xiao
424bb589a2 Make io_data_t destructor virtual 2013-01-17 14:54:18 +08:00
Cheer Xiao
664fee5c6e Use new IO_INVALID as default value of io_data_t::io_mode 2013-01-17 14:54:18 +08:00
Cheer Xiao
146a353085 rename enum io_mode -> io_mode_t; make io_data_t::io_mode that type 2013-01-17 14:54:18 +08:00
Cheer Xiao
b66233de78 Revert "Revert shared_ptr<io_data_t> changes until kinks are ironed out"
This reverts commit 77f1b1f0fe.
2013-01-11 14:18:10 -08:00
ridiculousfish
77f1b1f0fe Revert shared_ptr<io_data_t> changes until kinks are ironed out
https://github.com/fish-shell/fish-shell/pull/487

Revert "Merge branch 'oo-io' of git://github.com/xiaq/fish-shell into xiaq-oo-io"

This reverts commit f3c8f535a4, reversing
changes made to b02f6cf3bc.

Also reverts ac023f7588 and a79d3c680c
2013-01-04 02:05:30 -08:00
ridiculousfish
a79d3c680c Remove io_duplicate, which is no longer used 2013-01-04 01:05:35 -08:00
ridiculousfish
ac023f7588 Replace some shared_ptrs with const shared_ptr &. Don't use shared_ptr in postfork.cpp. Eliminate copy constructor in io_data_t. Simplify some other uses of shared_ptr<io_data_t> 2013-01-04 00:22:12 -08:00
Cheer Xiao
8b10b0a614 Convert all io_data_t copying to shared_ptr copying.
Copy constructor of io_data_t is removed.
2013-01-01 00:37:50 +08:00
Cheer Xiao
a9ada13a23 Use shared_ptr to manage io_data_t*. 2012-12-31 23:54:17 +08:00
ridiculousfish
9992b8eb0e Apply new indentation, brace, and whitespace style 2012-11-18 16:30:30 -08:00
Łukasz Niemier
47df1ae40a Remove trailing whitespaces and change tabs to spaces 2012-11-18 11:23:22 +01:00
ridiculousfish
9145d05397 Restore correct order of IO redirections
Fixes https://github.com/fish-shell/fish-shell/issues/281
2012-08-19 14:09:39 -07:00
ridiculousfish
61686aff34 Adopt posix_spawn (!)
Rewrite IO chains to be a vector of pointers, instead of a linked list
Removed io_transmogrify
2012-08-15 00:57:56 -07:00
ridiculousfish
84729c4dfa Additional warnings cleanup, effective C++ violations, dead code removal 2012-08-05 13:24:33 -07:00
Siteshwar Vashisht
ebfcee6e67 Fixed a crash on inputs like ls x>| less, where x doesn't exist in current directory. 2012-03-16 00:34:09 +05:30
ridiculousfish
14a35e7c21 Flip the switch to stop draining threads before exec (!) 2012-03-09 11:28:24 -08:00
ridiculousfish
d173bb6e0a A bunch of changes working towards eliminating all memory allocation after fork() 2012-03-08 23:21:07 -08:00
ridiculousfish
ed7c10f366 Implemented test as a builtin (!) 2012-03-07 00:54:01 -08:00
ridiculousfish
191221eec5 Final cleanup of io_data_t now that I recognize the bizarre way in which it shares output buffers (not sure how this ever worked before) 2012-03-04 02:35:30 -08:00
ridiculousfish
27f374a38b Some initial work on removing buffer_t from io_data_t 2012-03-03 23:56:35 -08:00
ridiculousfish
5fe7c065dc Squash a bunch of leaks 2012-02-21 19:33:11 -08:00
ridiculousfish
e5ff5f7484 Some hopefully good changes to get IOs off of halloc 2012-02-09 18:43:36 -08:00
ridiculousfish
8d2f107d61 Some changes to migrate towards C++ and a multithreaded model 2011-12-26 19:18:46 -08:00