c - Identifying programs "before" and "after" program in a pipeline are from the same "toolset" -
say, writting toolset every single tool operates on same textual data stream, parses it, operation on , returns textual stream using same syntax in original input. tools can combined (together other unix tools/scripts/whatever) in pipeline. because textual input processing (parsing) quite expensive, avoid in case 2 or more tools toolset 1 right after in pipeline , use binary streams instead (to store directly in memory struct, w/o useless "extra" parsing). possible know (using trick, inter-process communication, or whatever else) if tool "before" or "after" tool in pipeline part of toolset? guess unix env. not prepared such sort of "signalling" (afaik). ideas...
no, processes piped have no methods of two-way communication. if parsing expensive necessary (i'd guess isn't, profile it), have 2 options can think of:
- have master program takes options tell tools run, in order, , have run "parse" tool, followed requested tools (all using binary i/o), followed "output" tool. wouldn't terribly difficult expose individual tools, wrapped parse/output tools.
if users expected knowledgeable enough, have each tool allow flags tell them expect binary input , give binary output, users can chain like:
tool1 -o | tool2 -i -o | tool3 -i -o | tool4 -i
where
-o
means give binary output ,-i
means accept binary input.
Comments
Post a Comment