LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 03-07-2008, 08:55 AM   #1
sandiworld
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
vgscan produces no output using file descriptors on Oracle Enterprise Linux.


I wrote a simple program which will create a child process to execute a command and the output will be redirected to the file.

Please have a look at the following code ->

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>

void execute(char **argv)
{
pid_t pid;
int status;

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");
exit(1);
}

else if (pid == 0) /* for the child process: */
{
dup2(fStdOutDesc, fileno(stdout));
dup2(fStdErrDesc, fileno(stderr));

if (execvp(*argv, argv) < 0) /* execute the command */
{
printf("ERROR: exec failed...\n");
exit(1);
}
}
else /* for the parent process: */
{
while (wait(&status) != pid) ; /* wait for completion */
}
}

int main(void)
{
char cmd[1024];
char *argv[64];

printf("Enter the Command : ");
scanf("%s",&cmd); /* works for ls & doesn’t work for vgscan */
printf("\n");
argv[0]=cmd;
argv[1]='\0';
execute(argv);
return 0;
}



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.
 
Old 03-27-2008, 06:04 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If this is only the case for "Oracle Enterprise Linux" you'll have to find the differences between that and another distribution. If stracing doesn't give clues compare packages and settings or ask the vendor?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fdisk -l produces no output jakubi Debian 13 03-02-2011 09:50 AM
LXer: Oracle and Symantec Certify Veritas Data Center Solutions on Oracle(R) Enterprise Linux LXer Syndicated Linux News 0 07-18-2007 06:31 AM
LXer: Oracle(R) Database Standard Edition One and Oracle Enterprise Linux on HP Set New World Record for Price Performance with TPC-C Benchmark LXer Syndicated Linux News 0 06-12-2007 05:01 PM
less produces no output tvynr Linux - Software 14 06-09-2005 11:06 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 04:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration