9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] syscall silently kill processes
@ 2022-06-17  9:37 andrey100100100
  2022-06-17 13:46 ` Thaddeus Woskowiak
  0 siblings, 1 reply; 50+ messages in thread
From: andrey100100100 @ 2022-06-17  9:37 UTC (permalink / raw)
  To: 9fans

Hi all!

Strange behavior of syscall 'read' with signal 'alarm' in followed
simple program (ip/port - not matter):

-----------------------------------------------------------------------
#include <u.h>
#include <libc.h>
#include <thread.h>

static int
handler_alarm(void *, char *msg)
{
        if(strstr(msg, "alarm"))
                return 1;

        return 0;
}

static void
proc_udp(void *)
{
        char resp[512];
        char req[] = "request";
        int fd;

        threadnotify(handler_alarm, 1);

        if((fd = dial("udp!185.157.221.201!5678", nil, nil, nil)) >=
0){
                if(write(fd, req, strlen(req)) == strlen(req)){
                        fprint(1, "start\n");
                        alarm(2000);
                        read(fd, resp, sizeof(resp));
                        alarm(0);
                        fprint(1, "end\n");
                }
                close(fd);
        }

        threadexits(nil);
}

int mainstacksize = 5242880;

void
threadmain(int argc, char *argv[])
{
        for(int i = 0; i < 80; i++){
                proccreate(proc_udp, nil, 10240);
        }

        sleep(5000);
        threadexitsall(nil);
}
-----------------------------------------------------------------------


cpu% 6.out | grep end | wc -l
     33

sometimes little more or less
but

cpu% 6.out | grep start | wc -l
     80
     
always.

Testing on Miller's RPi and 9front (amd64 & RPi 2)


Why does read() kill process?
Why not always?
Why number of 'ended' processes arond 33?
This is normal behavior?
How to fix the program so that the processes do not lost?


Can someone point me in the right direction?


Thanks!
Andrey

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-M6b9bfae581b00133c66b93c2
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

end of thread, other threads:[~2022-06-29 13:15 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17  9:37 [9fans] syscall silently kill processes andrey100100100
2022-06-17 13:46 ` Thaddeus Woskowiak
2022-06-17 14:11   ` Jacob Moody
2022-06-17 14:39     ` Thaddeus Woskowiak
2022-06-17 15:06     ` andrey100100100
2022-06-17 16:08       ` Skip Tavakkolian
2022-06-17 16:11         ` Skip Tavakkolian
2022-06-17 16:16           ` Skip Tavakkolian
2022-06-17 17:42             ` adr
2022-06-17 16:11       ` Jacob Moody
2022-06-17 18:48         ` andrey100100100
2022-06-17 19:28           ` Jacob Moody
2022-06-17 21:15           ` adr
2022-06-18  6:40             ` andrey100100100
2022-06-18  8:37               ` adr
2022-06-18  9:22                 ` adr
2022-06-18 12:53                   ` Jacob Moody
2022-06-18 22:03                     ` andrey100100100
2022-06-19  5:54                     ` adr
2022-06-19  6:13                       ` Jacob Moody
2022-06-18 22:22                   ` andrey100100100
2022-06-18 16:57                 ` andrey100100100
2022-06-19  2:40                   ` adr
2022-06-19  5:01                     ` adr
2022-06-19  8:52                       ` andrey100100100
2022-06-19 10:32                         ` adr
2022-06-19 11:40                           ` andrey100100100
2022-06-19 12:01                             ` andrey100100100
2022-06-19 15:10                           ` andrey100100100
2022-06-19 16:41                             ` adr
2022-06-19 21:22                               ` andrey100100100
2022-06-19 21:26                                 ` andrey100100100
2022-06-20  4:41                                 ` adr
2022-06-20  5:39                                   ` andrey100100100
2022-06-20  5:59                                   ` adr
2022-06-20 15:56                                     ` andrey100100100
2022-06-20 22:29                                       ` Skip Tavakkolian
2022-06-21  7:07                                         ` andrey100100100
2022-06-21 11:26                                           ` adr
2022-06-21 13:03                                             ` andrey100100100
2022-06-21 13:22                                               ` adr
2022-06-28 15:28                                                 ` adr
2022-06-28 16:43                                                   ` ori
2022-06-28 18:19                                                   ` adr
2022-06-28 18:28                                                     ` adr
2022-06-28 19:09                                                   ` andrey100100100
2022-06-28 19:42                                                     ` adr
2022-06-29 13:14                                                       ` adr
2022-06-21 13:47                                             ` andrey100100100
2022-06-21  7:22                                         ` adr

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 NNTP newsgroup(s).