Denys Vlasenko wrote:
> On Wed, Jun 10, 2009 at 11:08 AM, Stefan Seyfried<[email protected]> wrote:
>>> I use something like this:
>>>
>>>   ret = system("tar ....");
>>>   if(ret)
>>>     eprintf("tar failed with error %d\n",ret);
>> Let me quote the man page of system(3) for you:
>>
>> RETURN VALUE
>>       The value returned is -1 on error (e.g.   fork(2)  failed),
>>       and  the return status of the command otherwise.  This lat-
>>       ter return status is in the format  specified  in  wait(2).
>>       Thus, the exit code of the command will be WEXITSTATUS(sta-
>>       tus).  In case /bin/sh could not be executed, the exit sta-
>>       tus will be that of a command that does exit(127).
>>
>> So your code is wrong, it's probably not busybox/tar's fault.
> 
> How did you conclude that it's not busybox/tar's fault?
> system("tar ..."); should normally return 0,

Which it actually does not, it returns WEXITSTATUS(256) == 1, if I parse the
WIF... macros correctly. And they should be used to check what's going on
which is probably "the application got some kind of signal". That's what I
meant with "the code is wrong" - and as long as something is not reproducible
with correct code, I usually refuse to accept it as a bug ;)

> so something is definitely is not working right.
> It may be a busybox tar problem.
> We do not have enough info yet to know, but the fact that
> tar file gets created tells that tar was successfully exec'ed.
> (it's not fork or exec failure, that is)
> 
> Uwe, can you "strace -f -o LOGFILE your_program"? It will show
> what's going on.

And checking for WEXITSTATUS(ret) as described in the system(3) manpage by
printing out the various conditions described in wait(2) might also be helpful
to find out what's going on:
  WIFEXITED(status)
  WEXITSTATUS(status)
  WIFSIGNALED(status)
  => if true, then WTERMSIG(status)

Best regards,

        Stefan
-- 
Stefan Seyfried
R&D Team Mobile Devices            |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg | "Well, surrounding them's out."

This footer brought to you by insane German lawmakers:
SUSE Linux Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to