This is the mail archive of the libc-help@sourceware.org mailing list for the glibc 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: Help: looking for equivalent syscall to shutdown() but for unix pipes


On Fri, Jan 18, 2019 at 8:39 PM Dmitry Goncharov
<dgoncharov@users.sf.net> wrote:
> int pipeFd;
> run = 1;
>
> void consumerThread()
> {
>   while (run)
>   {
>     ret = read(pipeFd, ...);
>
>     // do something with ret and the data
>   }
> }
>
> void stopConsumer()
> {
>   run = 0;
>   pthread_kill(tid, ...); // interrupt read.
>   join(...);
> }

That's quite a strong assumption that pthread_kill() would do the job.
When the data is being processed, you don't know which syscall might
be interrupted, who's going to catch the signal, how the resources are
going to be released and so on...
pthread_cancel() would not do the job either.

Regards,
-- 
Alexandre Bique


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