-1

I have a client - server application written in C. It's a basic application where client does an update request to server. If there are updates available, an archive file is sent to client. Further, the client unpack it, and run a specific bash script from that unpacked archive. That's the summary. I'll present bellow the C function that does the update on the client side:

void executeUpdates(char *path) {

    char    command[100];
    char    *tmp;

    strcpy(command, "tar xzf ");
    tmp = mystrcat(command, path);
    mystrcat(tmp, " -C /netnfork/updates/");
    system(command); //up to this point, I created the extract command and executed it.
    command[0] = '\0';
    path[strlen(path) - 7] = '\0';
    strcpy(command, path);
    strcat(command, "/update.sh");
    system(command);// up to this point, I created the command to run the update script and ran it.

}

The problem is as follows:

Problem: In the first updates when I put in update.sh script some simple commands (by simple I mean a few), it works well. When I put in this script some commands that do archive extraction, compilation with ./configure, make, make install, the script hangs in a specific point forever.

Specifically, in the update archive, I have six tar.bz archives that I need to extract and install. It works well for first 5 archives, but when script arrive to the point of the sixth tar.bz installation, it hangs on. If I run this script directly from terminal, it runs well, without any problem.

Question: Do anyone have some thoughts on solving this issue?

N.B. If you need more specific details or the script content, just tell me.

N.B1. I run the update C program as root.

4

2 回答 2

1

If I understood correctly your bash script runs fine up to some point and then something fails. Probably some process shows an error message but you don't read it because you don't inspect stderr. You should modify the script to write stdout and stderr of the failing step into e.g. /tmp/$$.err for debugging.

于 2013-06-17T11:53:15.367 回答
1

I'm not sure why user829755's answer didn't work for you since you said redirecting output solved the problem: maybe you meant redirecting the input from /dev/null solved the problem?

If something is trying to read from stdin the </dev/null will typically fix that.

于 2013-06-20T01:29:48.067 回答