Unix Technical Forum

system command returns 32512

This is a discussion on system command returns 32512 within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi, I am executing a C program in AIX 4.3 machine. The program sends email with the body redirected ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 08:27 AM
kiranhiremath@gmail.com
 
Posts: n/a
Default system command returns 32512

Hi,

I am executing a C program in AIX 4.3 machine.

The program sends email with the body redirected from a file.
I use mailx command ( sendmail utility ) in AIX.
The code has following lines:

########################
char *str = "mailx -s hi -c test@abc.com test2@abc.com < test.txt"

rc = system(str);

#########################

I execute this in a loop for many times.
For example, if i execute it for 10 times then 1-2 mails are not sent.
The return from system command for these 2-3 failed mails is 32512

I printed value of rc and it showed that rc=32512.
The mailx command was not invoked.
I saw in some groups, they have mentioned that the return 32512 is
because the exec of the child process failed.

I want to know the reason why the exec of the child process failed.
I have verified that the number of processes is not exceding the system
limit.
Can anyone please tell me the root cause of this return 32512.

Thanks and Regards
Kiran Hiremath

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 08:28 AM
Dan Foster
 
Posts: n/a
Default Re: system command returns 32512

In article <1137674999.453715.319480@f14g2000cwb.googlegroups .com>, kiranhiremath@gmail.com <kiranhiremath@gmail.com> wrote:
>
> I am executing a C program in AIX 4.3 machine.
>
> The program sends email with the body redirected from a file.
> I use mailx command ( sendmail utility ) in AIX.


> I printed value of rc and it showed that rc=32512.


32512 divided by 256 is 127... so it sounds like EOVERFLOW.

(grep 127 /usr/include/errno.h)

What is the size of file.txt? And the size of the target user's mailbox?

Is there any entry in 'errpt' for the problem?

Is the machine at 4.3.3 and fully patched?

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 08:28 AM
kiranhiremath@gmail.com
 
Posts: n/a
Default Re: system command returns 32512

Hi Dan,

I checked the file size and it is just 90 bytes.
And what is the entry 'errpt'. where can i find it.
I could see that when the system caommand failed, the mailx command was
not triggerred.
The target mailbox has a very huge size.
Also please not, some mailx commands which have a bigger file as a body
are executed successfully.

Also please let me know which are the patches which should be
installed.
What does the Error Number EOVERFLOW indicate?

Thanks and Regards
Kiran

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 08:28 AM
Dan Foster
 
Posts: n/a
Default Re: system command returns 32512

In article <1137679296.217843.257350@f14g2000cwb.googlegroups .com>, kiranhiremath@gmail.com <kiranhiremath@gmail.com> wrote:
>
> I checked the file size and it is just 90 bytes.
> And what is the entry 'errpt'. where can i find it.


It's a command. For example:

# /usr/sbin/errpt | more

But may not be needed.

> The target mailbox has a very huge size.


Ahh! Is the target mailbox at least 2,147,483,648 bytes?

If it is 2 GB or more, mailx will fail.

I would guess maybe because mailx could be written to only handle signed
32-bit numbers for file I/O access, or related to non-big files JFS.

So when the value is too big to fit in the off_t data type, you get the
overflow error (errno number 127).

Solution: reduce target user's mailbox size to less than 2 GB.

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2008, 08:28 AM
kiranhiremath@gmail.com
 
Posts: n/a
Default Re: system command returns 32512

Hi Dan,

The target user mailbox size is 50 MB.
The system command forks a child process and then it calls the exec
command.
I think the exec command is failing.
Can it be due to any memory error? For example current process memory
usage.
Do you have any idea on this?

Thanks
Kiran

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2008, 08:28 AM
Dan Foster
 
Posts: n/a
Default Re: system command returns 32512

In article <1137680269.009244.283360@g47g2000cwa.googlegroups .com>, kiranhiremath@gmail.com <kiranhiremath@gmail.com> wrote:
>
> The target user mailbox size is 50 MB.


Ahh. Hmm. Guess that's not a problem, then.

> The system command forks a child process and then it calls the exec
> command.
> I think the exec command is failing.
> Can it be due to any memory error? For example current process memory
> usage.


# /usr/bin/errpt | grep VMM

That will report if there were any virtual memory-related failures
logged.

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-05-2008, 08:28 AM
kiranhiremath@gmail.com
 
Posts: n/a
Default Re: system command returns 32512

Hi Dan,
Actaully my code is as follows:

################################################## ##############

length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) +
strlen(subject);
mailcommand = (char*)malloc(length + 128);

strcpy(mailcommand,"mailx -s \'");
strcat(mailcommand,subject);
strcat(mailcommand,"\' ");
strcat(mailcommand,"-c \"");
strcat(mailcommand,cc);
strcat(mailcommand,"\" ");
strcat(mailcommand,"-r \"");
strcat(mailcommand,replyto);
strcat(mailcommand,"\" ");
strcat(mailcommand,"\"");
strcat(mailcommand,to);
strcat(mailcommand,"\"");
strcat(mailcommand," ");

strcat(mailcommand,"< ");
strcat(mailcommand,tmpfilename);
strcat(mailcommand,"\n");

system(mailcommand);

free(mailcommand);

################################################## #####
The tmpfilename is the file which contains body.

Do you think there is any memory leak or any such thing here ?

Thanks and Regards
Kiran

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-05-2008, 08:28 AM
Laurenz Albe
 
Posts: n/a
Default Re: system command returns 32512

kiranhiremath@gmail.com wrote:
> Actaully my code is as follows:
>
> ################################################## ##############
>
> length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) +
> strlen(subject);
> mailcommand = (char*)malloc(length + 128);
>
> strcpy(mailcommand,"mailx -s \'");
> strcat(mailcommand,subject);
> strcat(mailcommand,"\' ");
> strcat(mailcommand,"-c \"");
> strcat(mailcommand,cc);
> strcat(mailcommand,"\" ");
> strcat(mailcommand,"-r \"");
> strcat(mailcommand,replyto);
> strcat(mailcommand,"\" ");
> strcat(mailcommand,"\"");
> strcat(mailcommand,to);
> strcat(mailcommand,"\"");
> strcat(mailcommand," ");
>
> strcat(mailcommand,"< ");
> strcat(mailcommand,tmpfilename);
> strcat(mailcommand,"\n");
>
> system(mailcommand);
>
> free(mailcommand);
>
> ################################################## #####
> The tmpfilename is the file which contains body.
>
> Do you think there is any memory leak or any such thing here ?


I cannot see a memory leak.
The '\n' at the end of the command is superfluous, but I don't think that
is the problem (since you say it occurs only sometimes).

Here's what the manual has to say about system(2) return values:

Return Values

Upon successful completion, the system subroutine returns the exit status
of the shell. The exit status of the shell is returned in the same manner
as a call to the wait or waitpid subroutine, using the structures in the
sys/wait.h file.

If the String parameter is a null pointer and a command processor is
available, the system subroutine returns a nonzero value. If the fork
subroutine fails or if the exit status of the shell cannot be obtained,
the system subroutine returns a value of -1. If the exec l subroutine
fails, the system subroutine returns a value of 127. In all cases, the
errno global variable is set to indicate the error.

What I would do in your place is change the code for debugging purposes:

#include <errno.h>
#include <string.h>
#include <stdio.h>

....

int rc;

....

rc = system(mailcommand);
printf("Executed command \"%s\", got return code %d, errno = %d (%s)\n",
mailcommand, rc, errno, strerror(errno));

Then let it run and examine the output. Share your observations!

Yours,
Laurenz Albe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-05-2008, 08:29 AM
Jeff Herrick
 
Posts: n/a
Default Re: system command returns 32512



On Fri, 19 Jan 2006 kiranhiremath@gmail.com wrote:

> Hi Dan,
> Actaully my code is as follows:
>
> ################################################## ##############
>
> length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) +
> strlen(subject);
> mailcommand = (char*)malloc(length + 128);
>
>


You need to include a sizeof() operator in your call to malloc. Your
current code assumes a character is one byte in size when most
likely you're dealing with either 32 bytes or 64 bytes per char i.e.

mailcommand = (char *)malloc(sizeof(char)*length+128)

This may not be your actual problem, but sloppy code like that will
come back and bite you at some point.

Cheers

JH
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-05-2008, 08:29 AM
Laurenz Albe
 
Posts: n/a
Default Re: system command returns 32512

Jeff Herrick <jherrick@igs.net> wrote:
>> length = strlen(to) + strlen(from) + strlen(replyto) + strlen(cc) +
>> strlen(subject);
>> mailcommand = (char*)malloc(length + 128);

>
> You need to include a sizeof() operator in your call to malloc. Your
> current code assumes a character is one byte in size when most
> likely you're dealing with either 32 bytes or 64 bytes per char i.e.
>
> mailcommand = (char *)malloc(sizeof(char)*length+128)
>
> This may not be your actual problem, but sloppy code like that will
> come back and bite you at some point.


As far as I know, the ANSI standard requires sizeof(char) to be 1.

Yours,
Laurenz Albe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:54 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com