sigpipe

Python subprocess.Popen PIPE and SIGPIPE

别说谁变了你拦得住时间么 提交于 2019-12-04 11:37:17
While I browsed posts, I ran into this example below on here , It is saying proc1.stdout.close() is needed to be called for appropriate exit of proc1 , generating SIGPIPE . import subprocess proc1 = subprocess.Popen(['ps', 'cax'], stdout=subprocess.PIPE) proc2 = subprocess.Popen(['grep', 'python'], stdin=proc1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc1.stdout.close() # Allow proc1 to receive a SIGPIPE if proc2 exits. out, err = proc2.communicate() print('out: {0}'.format(out)) print('err: {0}'.format(err)) However, I am not clear on that. Please fix my understanding. SIGPIPE

SIGPIPE error in iOS4 when app is running background and lock screen

被刻印的时光 ゝ 提交于 2019-12-03 09:11:08
I use BSD socket in my app to send and receive data on iphone4(iOS4.1),there are three situations in my app: app is running in foreground and screen locks, it's fine. app is running in background and screen does't lock, it's fine too(I use NSStream to send and receive data for keep app alive in background,it works fine.) app is running in background and screen locks, app running fine but always get the SIGPIPE error when app try to call sendto() or send() through UDP or TCP socket. I search a lot but get nothing useful,from here i know what SIGPIPE is , and i use setsockopt(sock, SOL_SOCKET,

What 's the meaning of the number 1 in SIG_IGN macro definition?

旧街凉风 提交于 2019-12-02 08:46:05
问题 #define SIG_IGN (void (*)(int))1 #define SIG_HOLD (void (*)(int))5 #define SIG_ERR ((void (*)(int))-1) I know what (void (*)(int)) means: cast unknown_name into pointer to function (int) returning void. But what's the meaning of the following 1 ? 回答1: The constant is used so that it can be distinguished from a valid function pointer. It has no meaning in itself (other than being distinct). For example: #define SIG_DFL ((__sighandler_t)0) /* default signal handling */ #define SIG_IGN ((_

TCP client-server SIGPIPE

不问归期 提交于 2019-12-02 00:06:19
I am designing and testing a client server program based on TCP sockets(Internet domain). Currently , I am testing it on my local machine and not able to understand the following about SIGPIPE. *. SIGPIPE appears quite randomly. Can it be deterministic? The first tests involved single small(25 characters) send operation from client and corresponding receive at server. The same code, on the same machine runs successfully or not(SIGPIPE) totally out of my control. The failure rate is about 45% of times(quite high). So, can I tune the machine in any way to minimize this. **. The second round of

Writing on a TCP socket closed by the peer

吃可爱长大的小学妹 提交于 2019-12-01 05:46:25
问题 I have a client-server application where each side communicate with the other via TCP socket. I properly establish the connection and then I crash the server BEFORE any data is written on the socket by the client. What I see is that the first write() attempt (client-side) is successful and it returns the actual number of written bytes, while the following ones return (as I expected) -1 (receiving a SIGPIPE ) and errno=EPIPE . Why the first write() is successful even if the socket is already

Handling SIGPIPE error in snakemake

别来无恙 提交于 2019-12-01 05:22:18
问题 The following snakemake script: rule all: input: 'test.done' rule pipe: output: 'test.done' shell: """ seq 1 10000 | head > test.done """ fails with the following error: snakemake -s test.snake Provided cores: 1 Rules claiming more threads will be scaled down. Job counts: count jobs 1 all 1 pipe 2 rule pipe: output: test.done jobid: 1 Error in job pipe while creating output file test.done. RuleException: CalledProcessError in line 9 of /Users/db291g/Tritume/test.snake: Command ' seq 1 10000 |

Using signals and sigpipe

我的梦境 提交于 2019-11-29 15:25:39
问题 I'm working on an assignment that involves writing a program to process data (calculate pi) using fork (processes), signals and select. I'm working right now on the signals and what I think I want to do is to use SIGPIPE so if the programs catches it, it tries to write to the pipe again (If a process tries to write to a pipe that has no reader, it will be sent the SIGPIPE). I use fork() in main() to assign each process the same work by sending them to the worker function. void worker(int id)

write on closed connection doesn't generate sigpipe immediately

こ雲淡風輕ζ 提交于 2019-11-29 08:46:44
I've this problem with my server/client on C. If I close the server socket after a SIGINT, and then I try to write on this closed connection from the client, I've to do write two times before than client generates SIGPIPE. Shouldn't it generate it immediately? Is this a normal behaviour or something I need to fix? This is my code. I'm testing things on ubuntu, same PC, connecting via 127.0.0.1. server.c sigset_t set; struct sigaction sign; int sock_acc; int sock; void closeSig(){ close(sock_acc); close(sock); exit(1); } int main(){ sigemptyset(&set); sigaddset(&set, SIGINT); sig.sa_sigaction =

Program received signal SIGPIPE, Broken pipe

佐手、 提交于 2019-11-28 16:28:49
问题 I write a client program based on posix sockets. The program creates multiple threads and is going to lock the server. But during debug in gdb time the program gives an info (error) (gdb) n Program received signal SIGPIPE, Broken pipe. [Switching to Thread 0xb74c0b40 (LWP 4864)] 0xb7fdd424 in __kernel_vsyscall () (gdb) Here's the code: #include <arpa/inet.h> #include <netdb.h> #include <netinet/in.h> #include <pthread.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys

write on closed connection doesn't generate sigpipe immediately

时光怂恿深爱的人放手 提交于 2019-11-28 02:01:53
问题 I've this problem with my server/client on C. If I close the server socket after a SIGINT, and then I try to write on this closed connection from the client, I've to do write two times before than client generates SIGPIPE. Shouldn't it generate it immediately? Is this a normal behaviour or something I need to fix? This is my code. I'm testing things on ubuntu, same PC, connecting via 127.0.0.1. server.c sigset_t set; struct sigaction sign; int sock_acc; int sock; void closeSig(){ close(sock