This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Bash returns incorrect process status

At 09:51 AM 9/17/2004 +0200, Peter Ekberg wrote:
>Pierre A. Humblet wrote:
>> FWIW, attached is a patch to bash that may improve its 
>> behavior on Cygwin.
>> The idea is that when a new process is stored in the memory array, any
>> existing process with the same pid is marked "reused". 
>> "reused" processes
>> are never considered when searching for a process by pid. 
>> They are still
>> still available, e.g. to get the status of processes in a job. 
>> It's a proof of principle code, not meant to be efficient. It 
>> can still print
>> a debug message on stderr.
>Tried it and it doesn't solve the problem for me. It shifts the trigger
>pattern though.

There was another problem. bash keeps track of the
"last_made_pid" and compares it to its previous value
to decide if it should wait on a process.

So if a new command has the same pid as the previous one,
bash won't wait on it.

You might think that this is OK as long as consecutive
forks return different pids. Wrong, because forks used
for some purposes, such as back tick evaluations,
don't count.

So bash is currently unreliable on any system where
processes don't have unique pids. If pid values are reused,
and all intervening forks serve only for backtick evaluations,
bash will return 0 status for a command.
Naturally this gets to be unlikely as the reuse period grows.

Here is another patch against the Cygwin release of bash.
It includes the previous one in this thread. Please try it.

Thanks to Bogdan Vacaliuc and Peter Ekberg for their help.


Attachment: pids.diff
Description: Text document

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]