- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- system() function in Linux returns -1
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-12-2012 01:30 AM
11-12-2012 01:30 AM
system() function in Linux returns -1
Hello,
We have installed our product in the Linux RHEL 5.5 machine. From our product we are using the system() function to spawn a different process which is passed as a command argument. The result is returned as -1 . It is currently happening only in one machine. The same code looks to be working correctly in other machines and the system() function returns the command status properly.
Is there any specific setting at the shell or kernel level because of this it can happen ? Any help on this would be appreciated.
Regards
kpj
- Tags:
- system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-12-2012 02:01 AM
11-12-2012 02:01 AM
Re: system() function in Linux returns -1
The -1 seems to imply it can't fork. Do you have the errno value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-12-2012 02:30 AM
11-12-2012 02:30 AM
Re: system() function in Linux returns -1
Is /bin/sh available on the system that has the problem?
Is your application running setuid or setgid on the system that has the problem?
Maybe something in your application is causing the argument of the system() function to be NULL in that particular system?
Or maybe the system is so out of memory that it cannot create new processes at the moment?
Is SELinux enabled? If it is, is the product running in a security context that disallows creation of child processes?
(Run "ps -Zp <application_PID>" to find the SELinux security context label associated with the process.)
Back when I was on a "Programming in C 101" course at an University, the professor recommended against using the system() function in major applications. His rationale was that it had rather limited facilities for programmatic error detection, making it hard or impossible to tell exactly what went wrong. Using fork()/vfork(), execve() (or one of the other functions of the exec() family) and wait() separately would allow for better error detection and reporting.
In his opinion, system() was good for small quick-and-dirty programs, but not much else. I think your issue shows he knew what he was talking about.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP