I am running a simple c program on Solaris 2.8 that calls a ksh shell
script x which contains an exit statement of 58 (exit 58).
cat xxx.c
#include <stdio.h>
#include <errno.h>
int
main()
{
FILE *ptr;
char buf[BUFSIZ];
char *cmd="./x";
if ((ptr = popen(cmd, "r")) != NULL)
{
while (fgets(buf, BUFSIZ, ptr) != NULL)
(void) printf("%s", buf);
printf("\nProce ss returned %d\n", pclose(ptr));
}
return 0;
}
cat x
#!/bin/ksh
exit 58
When I run the C program I get the following:
../xxx
Process returned 14848
I would have expected to see 58. Can anybody tell me why I am getting
14848.
man pclose
RETURN VALUES
The pclose() function returns the termination status of the
command. It returns -1 if stream is not associated with a
popen() command and sets errno to indicate the error.
Thanks in advance for all that answer this post 2 11350
"Stu" <be********@hot mail.com> wrote in message
news:a4******** *************** ***@posting.goo gle.com... I am running a simple c program on Solaris 2.8 that calls a ksh shell script x which contains an exit statement of 58 (exit 58).
cat xxx.c
#include <stdio.h> #include <errno.h>
int main() {
FILE *ptr;
char buf[BUFSIZ]; char *cmd="./x";
if ((ptr = popen(cmd, "r")) != NULL) { while (fgets(buf, BUFSIZ, ptr) != NULL) (void) printf("%s", buf);
printf("\nProce ss returned %d\n", pclose(ptr));
} return 0; }
cat x #!/bin/ksh exit 58
When I run the C program I get the following: ./xxx Process returned 14848
I would have expected to see 58. Can anybody tell me why I am getting 14848.
man pclose RETURN VALUES The pclose() function returns the termination status of the command. It returns -1 if stream is not associated with a popen() command and sets errno to indicate the error.
Thanks in advance for all that answer this post
This post asks about running a C program from a shell script on a Solaris
platform, none of which are at all related to the topic of this newsgroup,
which is the use of the standard C++ language. Try in a newsgroup related
to one of those topics. You might also check your doc's or header files (or
use google) to see if 14848 is a known error code in your system.
-Howard be********@hotm ail.com (Stu) wrote in message news:<a4******* *************** ****@posting.go ogle.com>... I am running a simple c program on Solaris 2.8 that calls a ksh shell script x which contains an exit statement of 58 (exit 58).
cat xxx.c
#include <stdio.h> #include <errno.h>
int main() {
FILE *ptr;
char buf[BUFSIZ]; char *cmd="./x";
if ((ptr = popen(cmd, "r")) != NULL) { while (fgets(buf, BUFSIZ, ptr) != NULL) (void) printf("%s", buf);
printf("\nProce ss returned %d\n", pclose(ptr));
} return 0; }
cat x #!/bin/ksh exit 58
When I run the C program I get the following: ./xxx Process returned 14848
I would have expected to see 58. Can anybody tell me why I am getting 14848.
man pclose RETURN VALUES The pclose() function returns the termination status of the command. It returns -1 if stream is not associated with a popen() command and sets errno to indicate the error.
Thanks in advance for all that answer this post
The returnvalue of the child process is in the top 16 bits. You have
to divide the returned value of pclose by 256, then you get the
searched return value of the child process. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Galt |
last post by:
I am writing a rudimentary shell. The (idealized) code is like this:
/* read_cmd returns argv */
char **read_cmd();
shell()
{
char **cmd;
while {
|
by: tshad |
last post by:
I have class method that is passing back a boolean, but it always returns a
false;
The class is:
***************************************************************************
public bool Delete()
{
int rowsAffected = 0;
DbObject myDbObject = new DbObject();
SqlParameter parameters = {
|
by: Sean Tynan |
last post by:
I want to find out the best way for a method to notify calling code of
situations such as validation errors, etc. that may occur during method
execution.
e.g. say I have a method (business logic layer) that inserts a user into a
database, and returns the newly created UserID:
public function CreateUser(userName as string, userEmail as string)
dim userID as integer
|
by: ehabaziz2001 |
last post by:
I am facing that error message with no idea WHY the reason ? "Abnormal
program termination"
E:\programs\c_lang\iti01\tc201\ch06\ownarr01o01
Enter a number : 25
More numbers (y/n)? y
Enter a number : 30
More numbers (y/n)? n
|
by: Ralf Assmann |
last post by:
Hi there,
we have the following problem using a DB2 version 7 on z/OS, referring
also <a
href="http://groups.google.de/group/comp.databases.ibm-db2/browse_thread/thread/2555018c0d364314/ea946c98e25ce4b7?lnk=gst&q=assmann&rnum=2#ea946c98e25ce4b7">this
thread</a>:
Using a java program with a connection to a DB2 using a type 2-driver,
we insert many datasets into the database in one transaction. The type
2-driver connects to the database...
| |
by: Michal Nazarewicz |
last post by:
Hi,
What does returning 0 from main() mean according to C89/C90 standard?
I've found that in C99 it means successful termination (7.20.4.3p5)
however as I'm editing book on C at Polish Wikibooks I'd like to know
what C89/C90 says about it - quotation from C89 or C90 would be nice.
Moreover, in C99 main() function is somewhat special because lack of
return statement is equivalent with returning zero (5.1.2.2.3p1). Is
it also the case...
|
by: Flyzone |
last post by:
I need to run a network program and return output in a variable name
without use temporany file.
So i tought to use popen (i'm using python 2.3, i can't upgrade).
RESULT = os.popen('command'+HOST, 'r')
I have a problem about it:
i need to kill the child if the program take more than 300 ms, but i
need also to wait this 300 ms to have the reply.
os.pclose(RESULT) give me:
AttributeError: 'module' object has no attribute 'pclose'
cause...
|
by: Logan Lee |
last post by:
Hi. I've written a small program to learn to write in C. But unfortunately the output is all jumbled up and not nice.
/* read_file.c
The whole point of this code is to read the entire content from a file then arrange the data as a single string. */
#include <stdio.h>
char* returnArrayFromFile(char* file_name) {
// Try opening a file
|
by: NotepadZ |
last post by:
I am getting a frustrating error when i try to insert into the table the trigger i created is on.
Any insight would be appreciated
Error:
db2 => INSERT INTO trstat VALUES ('340758A', 'POSITION', timestamp ( '2008-08-14-13.53.38.000000' ), '-', 272816, 'No Zone Match',
'TM4WIN', 365374, 'ONOAK')
DB21034E The command was processed as an SQL statement because it was not a
valid Command...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |