unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Threads + pipes = bad?
@ 2003-07-24  7:48 Robert Marlow
  2003-07-24 15:07 ` Robert Marlow
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Marlow @ 2003-07-24  7:48 UTC (permalink / raw)


Hi all 

I'm getting some problems with my use of a pipe within a thread in a
program I'm writing. Platform is Solaris 8.

Anyway, here's an example of a function I've called from within the
thread:

(define (email message)
  (let* ((address (assoc-ref message 'address))
         (message-text (assoc-ref message 'text))
         (mail-pipe (open-output-pipe (string-append "mailx -s \'" 
                                                     subject "\' "
				                     address)))
   (display message-text mail-pipe)
   (close-pipe))) 


And here's the errors I get:

In thread:
ERROR: In procedure dup2:
ERROR: Bad file number

and 

In thread:
ERROR: In procedure waitpid:
ERROR: No child processes


Can anyone shed some light on what's happening here? Is there contention
for file descriptors or something?

TIA


-- 
Regards,

Robert Marlow







_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Threads + pipes = bad?
  2003-07-24  7:48 Threads + pipes = bad? Robert Marlow
@ 2003-07-24 15:07 ` Robert Marlow
  2003-07-28 23:11   ` Kevin Ryde
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Marlow @ 2003-07-24 15:07 UTC (permalink / raw)


Nevermind, I think I fixed it by calling the function while the mutex
was locked. Bummar though; the whole point of using threads was to get
procedures like this one working concurrently.

I haven't really played with threads before... is there any reason I
shouldn't be able to unlock the mutex and _then_ call a procedure with a
pipe such as below? 

I'm guessing the way to speed the processing up without taking it out of
the mutex lock is to put the procedure in a separate executable script,
yeah?


On Thu, 2003-07-24 at 15:48, Robert Marlow wrote:
> Hi all 
> 
> I'm getting some problems with my use of a pipe within a thread in a
> program I'm writing. Platform is Solaris 8.
> 
> Anyway, here's an example of a function I've called from within the
> thread:
> 
> (define (email message)
>   (let* ((address (assoc-ref message 'address))
>          (message-text (assoc-ref message 'text))
>          (mail-pipe (open-output-pipe (string-append "mailx -s \'" 
>                                                      subject "\' "
> 				                     address)))
>    (display message-text mail-pipe)
>    (close-pipe))) 
> 
> 
> And here's the errors I get:
> 
> In thread:
> ERROR: In procedure dup2:
> ERROR: Bad file number
> 
> and 
> 
> In thread:
> ERROR: In procedure waitpid:
> ERROR: No child processes
> 
> 
> Can anyone shed some light on what's happening here? Is there contention
> for file descriptors or something?
> 
> TIA
> 
> 
> -- 
> Regards,
> 
> Robert Marlow
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
-- 
Regards,

Robert Marlow



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Threads + pipes = bad?
  2003-07-24 15:07 ` Robert Marlow
@ 2003-07-28 23:11   ` Kevin Ryde
  2003-07-31  8:20     ` Robert Marlow
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Ryde @ 2003-07-28 23:11 UTC (permalink / raw)


Robert Marlow <bobstopper@australispro.com.au> writes:
>
> Nevermind, I think I fixed it by calling the function while the mutex
> was locked. Bummar though; the whole point of using threads was to get
> procedures like this one working concurrently.

Does your main thread do anything evil?  Without actually trying it,
it seems that open-process might end up with all threads still running
in the forked child (until it exec's).


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Threads + pipes = bad?
  2003-07-28 23:11   ` Kevin Ryde
@ 2003-07-31  8:20     ` Robert Marlow
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Marlow @ 2003-07-31  8:20 UTC (permalink / raw)


My main process just brings up a few threads and then sits back in a
while loop doing nothing.

Actually, select's throwing file number errors at me as well. It seems
whenever I use a port, if it's outside a mutex lock it complains.


On Tue, 2003-07-29 at 07:11, Kevin Ryde wrote:
> Does your main thread do anything evil?  Without actually trying it,
> it seems that open-process might end up with all threads still running
> in the forked child (until it exec's).
-- 
Regards,

Robert Marlow







_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-31  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-24  7:48 Threads + pipes = bad? Robert Marlow
2003-07-24 15:07 ` Robert Marlow
2003-07-28 23:11   ` Kevin Ryde
2003-07-31  8:20     ` Robert Marlow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).