Deer all;
I think I have fix this problem.
The reason is
struct service {
/* list of all services */
struct listnode slist;
const char *name;
const char *classname;
unsigned flags;
pid_t pid;
time_t time_started; /* time of last start */
time_t time_crashed; /* first crash within inspection window */
int nr_crashed; /* number of times crashed within window */
uid_t uid;
gid_t gid;
gid_t supp_gids[NR_SVC_SUPP_GIDS];
size_t nr_supp_gids;
struct socketinfo *sockets;
struct svcenvinfo *envvars;
int nargs;
char *args[1];
struct action onrestart; /* Actions to execute on restart. */
/* keycodes for triggering this service via /dev/keychord */
int *keycodes;
int nkeycodes;
int keychord_id;
};
while we use the field 'char *args[1]' ,
static void *parse_service(struct parse_state *state, int nargs, char
**args)
{
struct service *svc;
if (nargs < 3) {
parse_error(state, "services must have a name and a program\n");
return 0;
}
if (!valid_name(args[1])) {
parse_error(state, "invalid service name '%s'\n", args[1]);
return 0;
}
svc = service_find_by_name(args[1]);
if (svc) {
parse_error(state, "ignored duplicate definition of service '%s'\n",
args[1]);
return 0;
}
nargs -= 2;
svc = calloc(1, sizeof(*svc) + sizeof(char*) * nargs);
if (!svc) {
parse_error(state, "out of memory\n");
return 0;
}
svc->name = args[1];
svc->classname = "default";
memcpy(svc->args, args + 2, sizeof(char*) * nargs);
svc->args[nargs] = 0;
svc->nargs = nargs;
svc->onrestart.name = "onrestart";
list_init(&svc->onrestart.commands);
list_add_tail(&service_list, &svc->slist);
return svc;
}
the memcpy(svc->args, args + 2, sizeof(char*) * nargs); is used the struct
svc->onrestart
memory.
so while the nargs > 8
the svc->args[8] == "onrestart"
but not your real args.
2009/3/11 eagle black <[email protected]>
> hi all,
> I found a bug at android platform.
>
> *Please describe the problem in as much detail as possible. Be sure to
> include:*
> *- Steps to reproduce the problem*
> 1 .
> modify init.hardware.rc (hardware is your platform hardware, such
>
> init.goldfish.rc)
> change
> service logcat /system/bin/logcat -r 1000 -v long -f /local/log/logcat.log
> oneshot
> to
> service logcat /system/bin/logcat -r 1000 -n 2 -v long -f
> /local/log/logcat.log
> oneshot
>
> because the /local/log room limited, we only need two logcat.logs
> so we add a argumenet -n 2 (default is 4, right?)
> 2 .
> run the phone
>
> 3 .
> #ps | grep logcat
> we will found the logcat service is not running.
>
> *- Sample source code demonstrating the problem*
> *- What you think the correct behavior should be.*
> if we use the old
> service logcat /system/bin/logcat -r 1000 -v long -f /local/log/logcat.log
> oneshot
>
> the service can running.
>
>
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---