From: Narendra B on
Hi, I'm facing this problem only on Macantosh OS, it works fine on
Windows and Linux.

Logic: Opens a pipe for reading output of a command, prints all lines
and then closes pipe!

On MAC, it gives following error for close $fp_job:

"Operation failed"

proc get_status {job_id} {
if { ! [catch {set fp_job [open "|some_process -job_id $job_id -
view" RDONLY]} ] } {
set job_line [gets $fp_job]
while { ! [eof $fp_job] } {
if { [regexp {^Status:\s+(\w+)} $job_line -> status ]} {
break
}
set job_line [gets $fp_job]
}
# following close on pipe fails only on MAC
close $fp_job
return $status
} else {
puts "Error: get_status failed for job_id |$job_id|"
return -1
}
}

What is the reason for this? If I modify the logic and REMOVE break
statement then the error is not seen!

Thanks,
Narendra
From: Narendra B on
On Apr 13, 6:17 pm, Narendra B <bhagw...(a)gmail.com> wrote:
> Hi, I'm facing this problem only on Macantosh OS, it works fine on
> Windows and Linux.
>
> Logic: Opens a pipe for reading output of a command, prints all lines
> and then closes pipe!
>
> On MAC, it gives following error for close $fp_job:
>
> "Operation failed"
>
> proc get_status {job_id} {
>   if { ! [catch {set fp_job [open "|some_process -job_id $job_id -
> view" RDONLY]} ] } {
>     set job_line [gets $fp_job]
>     while { ! [eof $fp_job] } {
>       if { [regexp {^Status:\s+(\w+)} $job_line -> status ]} {
>         break
>       }
>       set job_line [gets $fp_job]
>     }
>     # following close on pipe fails only on MAC
>     close $fp_job
>     return $status
>   } else {
>     puts "Error: get_status failed for job_id |$job_id|"
>     return -1
>   }
>
> }
>
> What is the reason for this? If I modify the logic and REMOVE break
> statement then the error is not seen!
>
> Thanks,
> Narendra

Problem identified.
The close was getting attempted even before the command some_process
was finishing its business! Som giving a 5 seconds delay (after 5000)
as a first statement inside the if solved the problem.

Any thoughts are welcomed.
From: Narendra B on
On Apr 13, 6:33 pm, Narendra B <bhagw...(a)gmail.com> wrote:
> On Apr 13, 6:17 pm, Narendra B <bhagw...(a)gmail.com> wrote:
>
>
>
>
>
> > Hi, I'm facing this problem only on Macantosh OS, it works fine on
> > Windows and Linux.
>
> > Logic: Opens a pipe for reading output of a command, prints all lines
> > and then closes pipe!
>
> > On MAC, it gives following error for close $fp_job:
>
> > "Operation failed"
>
> > proc get_status {job_id} {
> >   if { ! [catch {set fp_job [open "|some_process -job_id $job_id -
> > view" RDONLY]} ] } {
> >     set job_line [gets $fp_job]
> >     while { ! [eof $fp_job] } {
> >       if { [regexp {^Status:\s+(\w+)} $job_line -> status ]} {
> >         break
> >       }
> >       set job_line [gets $fp_job]
> >     }
> >     # following close on pipe fails only on MAC
> >     close $fp_job
> >     return $status
> >   } else {
> >     puts "Error: get_status failed for job_id |$job_id|"
> >     return -1
> >   }
>
> > }
>
> > What is the reason for this? If I modify the logic and REMOVE break
> > statement then the error is not seen!
>
> > Thanks,
> > Narendra
>
> Problem identified.
> The close was getting attempted even before the command some_process
> was finishing its business! Som giving a 5 seconds delay (after 5000)
> as a first statement inside the if solved the problem.
>
> Any thoughts are welcomed.- Hide quoted text -
>
> - Show quoted text -

What is the reason for this behavior, the reason I ask as it works
fine on Linux and Windows. The same issue is seen with two diff MAC
machines.
From: Erik Leunissen on
Narendra B wrote:
>
> What is the reason for this behavior, the reason I ask as it works
> fine on Linux and Windows. The same issue is seen with two diff MAC
> machines.

We can do very wild guesses here. My two cents:

Your previous post in this same thread suggests that there is an issue
related to processing time. It would be logical to pursue the cause of
the issue by inspecting aspects that may affect the processing at the
particular point in time on your particular machine where the issue occurs.

These aspects may have little to do with the type of OS, but rather with
resources available to the process or its I/O, like:
- CPU type/power
- CPU time consumed by the process to which your pipe communicates
- some of these processes waiting on I/O?
- CPU time consumed by unrelated processes running simultaneously
- ... ?

HTH,

Erik.
--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.