LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 04-11-2020, 11:02 PM   #1
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
error code 10


Am posting this question here because it only happens on the 64 bit FreeBSD server, not on my older 32 bit Linux desktop.

One particular binary, compiled cleanly from C source on the BSD server, in some cases aborts without any output, and returns code 10 (decimal ten), according to the shell message. This does not correspond to any exit code I've written into the C program.

What does error code 10 mean? So I can try to trouble-shoot. Am running this remotely on the BSD server as a shell command, not inside of a bash script. The C program is compiled using gcc

Perhaps this thread should be in the Linux-Server or Programming forum?
 
Old 04-12-2020, 02:38 AM   #2
shruggy
Member
 
Registered: Mar 2020
Posts: 609

Rep: Reputation: Disabled
I have zero experience with *BSD systems, but could it be this?
Quote:
10 ECHILD No child processes.
A wait(2) or waitpid(2) function was executed by a process that had no existing or unwaited-for child processes.
 
1 members found this post helpful.
Old 04-12-2020, 02:51 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
is this the return code (exit code) from that process? That means it can exit with it somehow.
I don't know how is your program written, if it can return with an exit code of a system call the post #2 can be valid (in that case you could use perror to print some info).
Otherwise you may need to use strace to find out what's happening (also you may rebuild it using debug flag).
Probably I would try to improve the error handling inside your code and put some logging to see what's going on.
(Without seeing the code hard to say anything).
 
Old 04-12-2020, 09:50 AM   #4
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411

Original Poster
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
I may be well over my head here. Here is my best noobee attempt at a further explanation:

This is a low-budget hosting server which allows me to compile executables, in this case a C program, and then execute the compiled binary via the site's simple user facility to "Run Shell Command". The compiling, execution, and all data files have file permissions set to my user ownership. Which is to say, the same as if I were doing everything on my home computer running Linux - where everything runs fine. Am now confident that this is not a matter of 32-bit home computer vs. 64-bit server. Am beginning to doubt whether it is a Linux vs BSD problem, either.

To answer the above, at the top of my C code, I do try to trap two types of abortive terminations:

Code:
signal (SIGTERM,TermSignal);
signal (SIGINT,IntSignal);
Both of the referenced routines print a message to stderr and then exit with a non-zero value (not 10).

Other conditions may cause the program to quit w/o a system error. If I run the program on the server with parameters that I know will cause one of these conditions resulting in an early failure (but not a system error), it executes as expected, printing an error message, and exiting with a non-zero value (not 10). When workable parameters are passed and the program enters in to its processing loop, the BSD server kicks it out with return value 10. My program traps nothing.

What I begin to suspect is that the server is killing this particular program for taking too much time in its initializing and repetitive processing loop. I fail to see what this has to do with a child process failure. Unless in this case, the hosting service's "Run Shell Command" is the main executable, and my program is the child process(??)

Last edited by dogpatch; 04-12-2020 at 09:57 AM. Reason: add "not 10"
 
Old 04-12-2020, 10:04 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
In that case I can only suggest you to insert some logging commands into that code. Just to know what is happening.
If it was an exit code: it has no any special meaning, may or may not be related to ECHILD. You need to know how your program will exit.
I still do not understand where is this 10 coming from. Signal handling is not related to it anyway (I think).
 
1 members found this post helpful.
Old 04-12-2020, 10:10 AM   #6
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411

Original Poster
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
Quote:
Originally Posted by pan64 View Post
In that case I can only suggest you to insert some logging commands into that code. Just to know what is happening.
Sounds like good advice.
 
Old 04-14-2020, 03:14 PM   #7
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411

Original Poster
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
Applying the above suggestion, it appears that my guess in post #4 above was correct. There's a lot of repetitive looping, so that - since my account on the hosting server is a low-priority one - the server kills the program for taking too much time. Will marked this as [Solved], which in this case means i have to keep doing this particular task offline (was hoping to make it a cron job).

Still not sure what return code 10 means. May my other guess above be correct, and the hosting service's "Run Shell Command" is the main executable, and my program is the child process? Or, as pan64 suggests, it has no particular meaning?
 
Old 04-15-2020, 12:08 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
if it was started from cron: cron always starts a shell and the command you configured will be executed in that shell. So probably yes, this shell reported this error - or probably not, it is not related at all.
But anyway you can try to limit the execution (for example if it was already running it will not be started again).
 
Old 05-20-2020, 05:36 AM   #9
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411

Original Poster
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
Have just marked this as [Unsolved] again, as i have learned a couple more details.

Recently, a different program running on the BSD server began crashing sometimes, with the same signal 10. My hosting service's tech guy said this means a bus error. Since this program must run on the server as well as on my home computer, i've spent some more time trying to figure out what's going on. Have tracked the problem down to a call from an assembly routine to a C function, which i've also written about in this Programming thread

This seems to answer my original question of this thread: that signal 10(ten) indicates a bus error. And that most likely the program i wrote about in this thread was failing for exactly the same reason: a failed call from assembly to a C function. And, as noted in the aforementioned thread, this happens intermittently, not all the time.

But am now more confused than ever. Am now suspecting that i'm looking at some random corruption of memory or of the stack pointer or something. But why on the FreeBSD server and not my home Linux box? Is it possible that the FreeBSD's GCC compiler or kernel do inter-language calls differently than in Linux?

One more detail: My hosting service often does what they call a 'realm update', meaning, i guess, that they make some tweeks to the operating system and environment on the server. Does someone in LQ-land know about FreeBSD 'realms', and what impact they might have on compiling an inter-language binary?

Will continue to puzzle and try to uncover the root problem. Meanwhile would welcome any tips.
 
Old 05-20-2020, 06:03 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
do you run the same binary on all those hosts?
 
Old 05-20-2020, 06:08 AM   #11
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411

Original Poster
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
No, there are a number of binaries. They run on two systems: my 32-bit linux home computer, and the 64-bit BSD server. They all seem to crash at the call from assembly to a C function. Am just now in the process of verifying that for the program that started me on posting this thread.
 
Old 05-20-2020, 06:16 AM   #12
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
Probably I misunderstood. Do you compile all on linux and run both on linux and BSD, or do you have a cross-compiler or ?
 
Old 05-20-2020, 06:59 AM   #13
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 411

Original Poster
Blog Entries: 4

Rep: Reputation: 181Reputation: 181
I compile native using gcc in both cases. Compile at home to run the binaries at home, and compile on the server for programs running on the server.

The makefile and C source code is the same, but i make variations in the assembly language source by way of pre-compile directives. So, for example, if there are parameters to be passed to the called function, for the 32-bit compile, i push the argument(s) on the stack, while for 64-but, i use the registers rdi, etc. You can see a little more on the above mentioned thread in the Programming forum.

As a noobie to 64-bit and to BSD, i may not be doing things correctly. What baffles me is why the programs usually run well, but only intermittently fail. And never crash on the home computer. Maybe a problem with how i'm handling the stack pointer in 64-bit?? Or something that must be coded slightly differently for BSD?? Which question is why i've re-opened this thread.
 
Old 05-20-2020, 07:21 AM   #14
shruggy
Member
 
Registered: Mar 2020
Posts: 609

Rep: Reputation: Disabled
Quote:
Originally Posted by dogpatch View Post
Or something that must be coded slightly differently for BSD??
Hmm, according to Wikipedia, Linux and BSD use the same calling convention.
 
Old 05-20-2020, 09:28 AM   #15
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,337

Rep: Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627Reputation: 4627
for me (right now) it looks like it is stable on 32bit, but unstable when compiled for 64 bit [or something like that).
I would probably try valgrind.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Parse error: parse error, unexpected '/' - can anyone see the error in this code? v@ny@ Programming 8 04-03-2010 04:07 PM
Error in Perl Code : Bad switch statement(Problem in code block)? near ## line # suyog255 Programming 4 02-20-2008 05:35 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Bug in c code calling bash code Linh Programming 11 08-12-2003 04:27 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 06:28 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration