pipe sort-anexercise in plumbing so easy

时间:2024-11-06 18:06:37

contact me help-assignment

Internally, the program must be organized into 3 types of processes. A single process reads the input parsing the lines into words, a group of processes does the sorting, and a single process suppresses and counts duplicate words and writes the output. You should organize the processes so that
every parent waits for its children, and if any process exits in error the main process returns the error code in its exit.

NOTES:
. You must use the system sort command (/usr/bin/sort) with no
arguments to do the actual sorting,

·You must not use any disk files, or large amounts of memory. There is
NO LIMIT on how large the input may be, and you should test with large input files.
· If there is more than one sorter, Parse distributes the words round
robin to the sorts
· All the I/O is done using the buffered I/O library (fget, fputc, etc), you
will need fdopen for attaching to the pipes.
·Words are all alphabetic and case insensitive with the parser
converting all aiphabetic characters to lower case. Any non-alphabetic characters delimit words and are discarded.
. The “short” and “long”parameters affect the parsing. Words with
“short" characters or less are discarded, words with “long"characters or greater are truncated to “long" characters.
. The output MUST have the count left justified in a 10 character field followed immediately by the word.

Example

short=2

long=6
This is nonsense abc-def$@#abc

some more of this


2   abc

1   def

1   more

1   nonsen

1   some

1   this