Process exited


I’am facing to an issue with the write(int fd, char* buffer, size_t length) function.

I wrote a simple code that writes some bytes on a socket. It works fine until the server closed the connection.
Actually, when the connection is closed by the server, instead of returning -1 the write function “crashed” and the process is killed.

Here are legato logs:

00:52:29 INFO | supervisor[565]/security T=main | proc.c proc_SigChildHandler() 1253 | Process 'helloWorld' (PID: 10771) has exited due to signal 13.
00:52:29 -WRN- | supervisor[565]/security T=main | proc.c GetFaultAction() 1142 | Unrecognized fault action for process 'helloWorld'.  Assume fault action is 'ignore'.
00:52:29 *CRT* | supervisor[565]/security T=main | app.c app_SigChildHandler() 1439 | The process 'helloWorld' in app 'Test' has faulted and will be ignored in accordance with its fault policy.
00:52:29 INFO | supervisor[565]/security T=main | app.c app_SigChildHandler() 1483 | app 'Test' has stopped.
00:52:29 INFO | supervisor[565]/security T=main | sandbox.c sandbox_Remove() 1257 | 'Test' sandbox removed.
00:52:29 INFO | supervisor[565]/supervisor T=main | supervisor.c DeleteAppObj() 487 | Application 'Test' has stopped.

And here the code of my (test) application:

int sock; // socket fd

static int sock_connect() {
struct addrinfo *addrInfo;
struct addrinfo hints = { 0, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL, NULL };

int res;
errno = 0;

if ((res = getaddrinfo("", "1234", &hints, &addrInfo)) != 0) {
	LE_ERROR("Cannot get address info: %s\n", gai_strerror(res));
	return -1;
sock = socket(addrInfo->ai_family, addrInfo->ai_socktype, addrInfo->ai_protocol);
if (sock == -1) {
	LE_ERROR(" Cannot create socket: %s\n", strerror(errno));
	return -1;

if (connect(sock, addrInfo->ai_addr, addrInfo->ai_addrlen) == -1) {
	LE_ERROR(" Cannot connect to server: %s\n", strerror(errno));
	return -1;
LE_DEBUG("Connected to server");
return 0;


if (sock_connect() == 0) {
int n = 0;
while (n >= 0) {
n=write(sock, “hello\n”, 6);

The application is connected to a netcat server running on my laptop: netcat -l -p 1234

Here are netcat “logs”:

[/cnetcat -l -p 1234
^C   // I manually killed the server => My legato app crashed with log quoted before 

I there something wrong in my code ? or is this a legato / or stdlib bug ?
If so how can I worked around this problem ?

Many thanks for your help !


Hi David,

you need to handle SIGPIPE when you use write with a socket. See the glibc documentation at … nding-Data

You can either use a native signal handler or use our signals API.


Thanks for your help Andrew !

It helped me to solve my problem