11-30-2006
pclose returning -1
Hi all,
In my application i am trying to select some text & then give it to print. for this i am opening a stream using popen & then later closing using pclose.
Now this is working fine in my environment (solaris) but the pclose function is failing at my clients m/c. Even though print is happening (i.e, no problem with the implementation) but still as pclose is failing it will throw an error message.
I have read pclose fails due to some problem with waitpid(). But what is that trouble ?
Also he has captured the truss output ( system calls made by the appln) which are as follows :
29340: time() = 1164271259
29340: time() = 1164271259
29340: llseek(9, 0, SEEK_CUR) = 605
29340: close(9) = 0
29340: time() = 1164271259
29340: unlink("/tmp//45655e9b03dde") = 0
29340: fstat64(1, 0xFFBFA930) = 0
request id is bw-b15rd-185608 (1 file(s))
29340: write(1, " r e q u e s t i d i".., 42) = 42
29340: _exit(0)
29338: waitid(P_PID, 29340, 0xFFBFE5F0, WEXITED|WTRAPPED|WNOWAIT) = 0
29338: getpgid(29340) = 29306
29338: waitid(P_PID, 29340, 0xFFBFE5F0, WEXITED|WTRAPPED) = 0
29338: _exit(0)
29307: Received signal #18, SIGCLD, in waitid() [caught]
29307: siginfo: SIGCLD CLD_EXITED pid=29338 status=0x0000
29307: waitid(P_PID, 29338, 0xFFBFC0B0, WEXITED|WTRAPPED|_WNOCHLD) Err#4 EINTR
29307: sigprocmask(SIG_SETMASK, 0xFFBFBCB4, 0x00000000) = 0
29307: wait() = 29338 [0x0000]
29307: sigprocmask(SIG_SETMASK, 0xFEFEA074, 0xFFBFBA68) = 0
29307: lwp_unpark(1, 1) = 0
29307: setcontext(0xFFBFBA78)
29307: waitid(P_PID, 29338, 0xFFBFC0B0, WEXITED|WTRAPPED|_WNOCHLD) Err#10 ECHILD
29307: uname(0xFFBFB768) = 1
29307: getpid() = 29307 [29306]
29307: write(3, "12\0\0\b\0\0\0 -\0\002 >".., 5420) = 5420
29307: read(3, 0xFFBFBE00, 32) Err#11 EAGAIN
29307: read(3, "02 @ b @13F98DA3\0\0\0 -".., 32) = 32
29307: read(3, 0xFFBFBE00, 32) Err#11 EAGAIN
29307: read(3, "1C : b A\0\0\0 -\0\002 >".., 32) = 32
29307: read(3, "16\0 b b\0C805B3\0C805B3".., 32) = 32
Can some 1 tell me y pclose is returning -1 every time ?
THanks
Nimisha
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to return one value from sqlplus to UNIX environment. Can anyone give me an example?
i.e. select username from v$session where sid=15;
This query will return username value which I require in UNIX after exiting from sqlplus.
Malay (1 Reply)
Discussion started by: malaymaru
1 Replies
2. UNIX for Dummies Questions & Answers
Hi all,
I have a mainframe file which i am ftping to unix box.
even though i have three records in my mainframe file the file on unix is coming as a single record.
Can you help me out.
Thanks,
Hari (3 Replies)
Discussion started by: harikiranr
3 Replies
3. Shell Programming and Scripting
Hi All
In my script, I can call on several functions. I have a logging function that is called by any of these functions. What I would like is some way of identifying which function I am using and pass this to the log function as some parameter.
Is there some built in command or way of... (3 Replies)
Discussion started by: kingpin2502
3 Replies
4. Red Hat
Hi
Need some help, bit of a noobie here.
This command work perfectly with unix. returns a value of 1 which is what i want.
ps -eo user,comm |grep -v grep |grep -c /path to file
When i run the same command on a linux server it returns a value of 0.,
something maybe wrong with the command.... (4 Replies)
Discussion started by: wneutt
4 Replies
5. UNIX for Advanced & Expert Users
Hi
I am trying to use popen function with wrtie option to give inputs to ftp command.
#include "stdio.h"
int main(int argv ,char *argc)
{
int size=0;
char *buf;
FILE *fp;
fp = popen("ftp","w");
while(getline(&buf,&size,stdin) != -1)
write(fp,buf);... (0 Replies)
Discussion started by: kumaran_5555
0 Replies
6. Programming
If i have the pointer to the pipe, which is given to pclose, what exactly does pclose do with it? (10 Replies)
Discussion started by: omega666
10 Replies
7. Shell Programming and Scripting
Dear Friends,
I need your help once more.
I want to write a simple select as follows
select amount from books
where sr=1234
However, if value of "Amount" is negative then it should print it as follows.
"3000-" and not as "-3000"
Can you help me in this?
Waiting for reply
Anu. (2 Replies)
Discussion started by: anushree.a
2 Replies
8. Shell Programming and Scripting
hello i write a script which calculate free space but he always is 0 thats wrong with my script?
getFileSystemPerformanceData()
{
if ; then
if grep -q "Ubuntu" /etc/issue ; then
CMD="df -lP | grep -v "\/home" | grep -v "\/dev/mapper/VolGroup-lv_root""
elif grep... (5 Replies)
Discussion started by: donatas1234
5 Replies
9. UNIX for Dummies Questions & Answers
My problem in brief is that I execute a script from another script and I can not pick up the return code from that script, or otherwise I am not returning from that script. I have an echo in the executed script and we get a response code of 0 and exit that script with the return code. I then try to... (1 Reply)
Discussion started by: Charles Swart
1 Replies
10. What is on Your Mind?
hey guys,
Im back! I hadnt thought about yall in a long time. I was googling away this morning and found a solution I needed from unix.com.
good to see yall are still here and going strong!
Im working as a Bladelogic Automation Engineer and have been doing HP and BMC server automation... (0 Replies)
Discussion started by: Kelam_Magnus
0 Replies
LEARN ABOUT ULTRIX
pclose
popen(3) Library Functions Manual popen(3)
Name
popen, pclose - initiate I/O to/from a process
Syntax
#include <stdio.h>
FILE *popen(command, type)
char *command, *type;
pclose(stream)
FILE *stream;
Description
The arguments to are pointers to null-terminated strings containing respectively a shell command line and an I/O mode, either "r" for read-
ing or "w" for writing. It creates a pipe between the calling process and the command to be executed. The value returned is a stream
pointer that can be used (as appropriate) to write to the standard input of the command or read from its standard output.
A stream opened by should be closed by which waits for the associated process to terminate and returns the exit status of the command.
Because open files are shared, a type "r" command may be used as an input filter, and a type "w" as an output filter.
Diagnostics
The routine returns a null pointer if files or processes cannot be created, or the shell cannot be accessed.
The routine returns -1 if stream is not associated with a `popened' command.
Restrictions
Buffered reading before opening an input filter may leave the standard input of that filter mispositioned. Similar problems with an output
filter may be forestalled by careful buffer flushing, for instance, with For further information, see
The routine always calls and never calls
See Also
sh(1), pipe(2), wait(2), system(3), fclose(3s), fopen(3s)
popen(3)