How does Erlang kill port processes?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How does Erlang kill port processes?

Albin Stigö-2
Hello,

I have a program that relies on C API calls to the Linux bluetooth
stack (bluez) so I wrote a port program for that...

There seems to be a bug in the version of the bluez stack I'm using
that requires programs to clean up after themselves or the program
will fail on the next execution (I guess some garbage state in driver
/ hardware).

I have tried to catch SIGPIPE/SIGTERM and check for EPIPE in my port
but it doesn't seem to work. How does Erlang kill ports? SIGKILL?

Any ideas on how to clean up on exit..? I realise this is very fragile
but as of now I need to work around this bug...


--Albin
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How does Erlang kill port processes?

Ali Sabil
Hi Albin,

The Erlang runtime doesn't actually kill the port, but just closes the pipe. You port should then detect an end-of-file on its input pipe.

Best,
Ali

On Sun, Jul 16, 2017 at 6:28 PM, Albin Stigö <[hidden email]> wrote:
Hello,

I have a program that relies on C API calls to the Linux bluetooth
stack (bluez) so I wrote a port program for that...

There seems to be a bug in the version of the bluez stack I'm using
that requires programs to clean up after themselves or the program
will fail on the next execution (I guess some garbage state in driver
/ hardware).

I have tried to catch SIGPIPE/SIGTERM and check for EPIPE in my port
but it doesn't seem to work. How does Erlang kill ports? SIGKILL?

Any ideas on how to clean up on exit..? I realise this is very fragile
but as of now I need to work around this bug...


--Albin
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How does Erlang kill port processes?

Albin Stigö-2
Hi,

Ah ok that should solve it! I read from a Bluetooth socket and wrote to stdout using blocking io and wasn't reading from stdin at all... That's why I got confused about how Erlang killed the process. Changed to using poll and check for POLLHUP on stdin.


Thanks,
Albin

On Jul 16, 2017 19:40, "Ali Sabil" <[hidden email]> wrote:
Hi Albin,

The Erlang runtime doesn't actually kill the port, but just closes the pipe. You port should then detect an end-of-file on its input pipe.

Best,
Ali

On Sun, Jul 16, 2017 at 6:28 PM, Albin Stigö <[hidden email]> wrote:
Hello,

I have a program that relies on C API calls to the Linux bluetooth
stack (bluez) so I wrote a port program for that...

There seems to be a bug in the version of the bluez stack I'm using
that requires programs to clean up after themselves or the program
will fail on the next execution (I guess some garbage state in driver
/ hardware).

I have tried to catch SIGPIPE/SIGTERM and check for EPIPE in my port
but it doesn't seem to work. How does Erlang kill ports? SIGKILL?

Any ideas on how to clean up on exit..? I realise this is very fragile
but as of now I need to work around this bug...


--Albin
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...