mirror of
https://github.com/vale981/yabar
synced 2025-03-05 17:41:40 -05:00
Merge pull request #33 from Lindenk/bigger_blk_buffer
Increase buffer size to 4096 & omit clearing buffer using memset
This commit is contained in:
commit
a40894b8f2
2 changed files with 26 additions and 11 deletions
|
@ -22,11 +22,12 @@ static void ya_exec_redir_once(ya_block_t *blk) {
|
|||
execl(yashell, yashell, "-c", blk->cmd, (char *) NULL);
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
else {
|
||||
wait(NULL);
|
||||
if (read(opipe[0], blk->buf, BUFSIZE) != 0) {
|
||||
ya_draw_pango_text(blk);
|
||||
}
|
||||
|
||||
ssize_t read_ret = read(opipe[0], blk->buf, BUFSIZE);
|
||||
if (read_ret < 0) {
|
||||
fprintf(stderr, "Error with block %s: %s\n", blk->name, strerror(errno));
|
||||
} else if (read_ret > 0) {
|
||||
ya_draw_pango_text(blk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,9 +48,12 @@ static void ya_exec_redir_period(ya_block_t *blk) {
|
|||
blk->pid = pid;
|
||||
//close(opipe[1]);
|
||||
wait(NULL);
|
||||
if (read(opipe[0], blk->buf, BUFSIZE) != 0) {
|
||||
ssize_t read_ret = read(opipe[0], blk->buf, BUFSIZE);
|
||||
if (read_ret < 0) {
|
||||
fprintf(stderr, "Error with block %s: %s\n", blk->name, strerror(errno));
|
||||
} else if (read_ret > 0) {
|
||||
blk->buf[read_ret] = '\0';
|
||||
ya_draw_pango_text(blk);
|
||||
memset(blk->buf, '\0', BUFSIZE);
|
||||
}
|
||||
sleep(blk->sleep);
|
||||
}
|
||||
|
@ -69,9 +73,19 @@ static void ya_exec_redir_persist(ya_block_t *blk) {
|
|||
}
|
||||
blk->pid = pid;
|
||||
close(opipe[1]);
|
||||
while (read(opipe[0], blk->buf, BUFSIZE) != 0) {
|
||||
ya_draw_pango_text(blk);
|
||||
memset(blk->buf, '\0', BUFSIZE);
|
||||
|
||||
ssize_t read_ret;
|
||||
while (1) {
|
||||
read_ret = read(opipe[0], blk->buf, BUFSIZE);
|
||||
if(read_ret == 0) {
|
||||
break;
|
||||
} else if (read_ret < 0) {
|
||||
fprintf(stderr, "Error with block %s: %s\n", blk->name, strerror(errno));
|
||||
continue;
|
||||
} else {
|
||||
blk->buf[read_ret] = '\0';
|
||||
ya_draw_pango_text(blk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define YABAR_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#define __USE_XOPEN2K //for setenv implicit function decleration warning
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -39,7 +40,7 @@
|
|||
|
||||
extern char *strdup(const char *s); //to suppress implicit decleration warning for strdup
|
||||
|
||||
#define BUFSIZE 512
|
||||
#define BUFSIZE 4096
|
||||
#define CFILELEN 256
|
||||
#define YA_DEF_FONT "sans bold 9"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue