vm/file-editor: connect /dev/null as stdin (#657)
If stdin is closed (not connected to /dev/null) first opened file will get fd=0 and will be treated as stdin.
This commit is contained in:
parent
f33d2e4f42
commit
4837fb8f00
@ -57,7 +57,7 @@ main()
|
|||||||
{
|
{
|
||||||
struct stat stat_pre, stat_post, session_stat;
|
struct stat stat_pre, stat_post, session_stat;
|
||||||
char *filename = get_filename();
|
char *filename = get_filename();
|
||||||
int child, status, log_fd;
|
int child, status, log_fd, null_fd;
|
||||||
char var[1024], val[4096];
|
char var[1024], val[4096];
|
||||||
FILE *env_file;
|
FILE *env_file;
|
||||||
FILE *waiter_pidfile;
|
FILE *waiter_pidfile;
|
||||||
@ -100,7 +100,9 @@ main()
|
|||||||
perror("fork");
|
perror("fork");
|
||||||
exit(1);
|
exit(1);
|
||||||
case 0:
|
case 0:
|
||||||
close(0);
|
null_fd = open("/dev/null", O_RDONLY);
|
||||||
|
dup2(null_fd, 0);
|
||||||
|
close(null_fd);
|
||||||
|
|
||||||
env_file = fopen("/tmp/qubes-session-env", "r");
|
env_file = fopen("/tmp/qubes-session-env", "r");
|
||||||
while(fscanf(env_file, "%1024[^=]=%4096[^\n]\n", var, val) == 2) {
|
while(fscanf(env_file, "%1024[^=]=%4096[^\n]\n", var, val) == 2) {
|
||||||
|
Loading…
Reference in New Issue
Block a user