Skip to content

Commit

Permalink
Interrupt handling for pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Jan 28, 2025
1 parent fbd6e20 commit d7a8bbd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
1 change: 0 additions & 1 deletion cligen_cvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ cvec_add(cvec *cvv,
return NULL;
}
len = cvv->vr_len + 1;

if ((cvv->vr_vec = realloc(cvv->vr_vec, len*sizeof(cg_var))) == NULL)
return NULL;
cvv->vr_len = len;
Expand Down
14 changes: 10 additions & 4 deletions cligen_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,16 @@ cligen_output(FILE *f,
goto done;
if (s != -1){
if (write(s, inbuf, inbuflen) < 0){
perror("cligen_output write on pipe socket");
close(s);
cli_pipe_output_socket_set(-1);
goto done;
switch (errno){
case EPIPE:
break;
default:
perror("cligen_output write on pipe socket");
close(s);
cli_pipe_output_socket_set(-1);
goto done;
break;
}
}
}
else{
Expand Down
10 changes: 8 additions & 2 deletions cligen_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,14 @@ cligen_eval_pipe_post(cligen_handle h,
/* Read until EOF */
while (ret != 0) {
if ((len = read(s, buf, 4096)) < 0){
perror("cli_pipe_exec_cb, read");
goto done;
switch (errno){
case ECONNRESET:
break;
default:
perror("cligen_eval_pipe_post, read");
goto done;
break;
}
}
if (len == 0)
break;
Expand Down
4 changes: 2 additions & 2 deletions cligen_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
* @param[in] cvv cligen variable vector
* @param[in] name Name to set (or NULL)
* @param[val] val String value
* @retval 0 OK
* @retval -1 Error
* @retval 0 OK
* @retval -1 Error
*/
int
cvec_add_string(cvec *cvv,
Expand Down

0 comments on commit d7a8bbd

Please sign in to comment.