Results 1 to 1 of 1
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Mar 2008
vgscan produces no output using file descriptors on Oracle Enterprise Linux.
Please have a look at the following code ->
void execute(char **argv)
int fStdOutDesc = open("/tmp/outfile", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
int fStdErrDesc = open("/tmp/errfile", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
printf("Out file Desc dup2 is %d\n",fStdOutDesc);
printf("Err file Desc dup2 is %d\n",fStdErrDesc);
if ((pid = fork()) < 0) /* fork a child process */
printf("ERROR: forking child process failed...\n");
else if (pid == 0) /* for the child process: */
if (execvp(*argv, argv) < 0) /* execute the command */
printf("ERROR: exec failed...\n");
else /* for the parent process: */
while (wait(&status) != pid) ; /* wait for completion */
printf("Enter the Command : ");
scanf("%s",&cmd); /* works for ls & doesn’t work for vgscan */
After running above program, it will prompt for an input (command), if you enter “ls”, the output of the “ls” command is redirected to /tmp/outfile, whereas after entering vgscan, there will not be anything in either /tmp/outfile or /tmp/errfile.
This problem is particularly with few commands like vgscan, pvscan, vgdisplay, lvdisplay etc whereas these commands give output if ran through shell.
This is the case for only Oracle Enterprise Linux. The same program works fine on other Linux versions.
Any help regarding this would be very much helpful.