~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to util/initctl.c

  • Committer: Scott James Remnant
  • Date: 2009-02-20 22:22:48 UTC
  • Revision ID: scott@netsplit.com-20090220222248-0yovfzpaeaz4408f
* util/initctl.c (job_info_output, output_name, handle_job_list)
(handle_job_instance, handle_job_instance_end)
(handle_job_status, handle_job_process, handle_job_status_end)
(handle_event, env_option),
* util/telinit.c (main),
* util/shutdown.c (main, shutdown_now, timer_callback, wall): 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* upstart
2
2
 *
3
 
 * Copyright © 2008 Canonical Ltd.
 
3
 * Copyright © 2009 Canonical Ltd.
4
4
 * Author: Scott James Remnant <scott@netsplit.com>.
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
545
545
         * that in the line; appending it to the name, or a whitespace prefix
546
546
         */
547
547
        if (name) {
548
 
                NIH_MUST (state = nih_sprintf (NULL, "%s (%s) %s", name,
 
548
                state = NIH_MUST (nih_sprintf (NULL, "%s (%s) %s", name,
549
549
                                               job_goal_name (info->goal),
550
550
                                               job_state_name (info->state)));
551
551
                nih_free (name);
552
552
        } else if (show_ids) {
553
 
                NIH_MUST (state = nih_sprintf (NULL, "    [#%u] (%s) %s",
 
553
                state = NIH_MUST (nih_sprintf (NULL, "    [#%u] (%s) %s",
554
554
                                               info->id,
555
555
                                               job_goal_name (info->goal),
556
556
                                               job_state_name (info->state)));
557
557
        } else {
558
 
                NIH_MUST (state = nih_sprintf (NULL, "    (%s) %s",
 
558
                state = NIH_MUST (nih_sprintf (NULL, "    (%s) %s",
559
559
                                               job_goal_name (info->goal),
560
560
                                               job_state_name (info->state)));
561
561
        }
642
642
        nih_assert (name != NULL);
643
643
 
644
644
        if (show_ids) {
645
 
                NIH_MUST (str = nih_sprintf (NULL, "%s [#%u]", name, id));
 
645
                str = NIH_MUST (nih_sprintf (NULL, "%s [#%u]", name, id));
646
646
        } else {
647
 
                NIH_MUST (str = nih_strdup (NULL, name));
 
647
                str = NIH_MUST (nih_strdup (NULL, name));
648
648
        }
649
649
 
650
650
        return str;
842
842
 
843
843
        event_caused = FALSE;
844
844
 
845
 
        NIH_MUST (current_list = nih_alloc (NULL, 0));
 
845
        current_list = NIH_MUST (nih_alloc (NULL, 0));
846
846
        current_list_sz = 0;
847
847
 
848
848
        return 0;
941
941
                if (! event_caused)
942
942
                        num_responses++;
943
943
 
944
 
        NIH_MUST (current_instance = nih_new (current_list, JobInfo));
 
944
        current_instance = NIH_MUST (nih_new (current_list, JobInfo));
945
945
 
946
946
        nih_alloc_reparent (name, current_instance);
947
947
 
995
995
        if (current_list) {
996
996
                JobInfo **new_list;
997
997
 
998
 
                NIH_MUST (new_list = nih_realloc (current_list, NULL,
 
998
                new_list = NIH_MUST (nih_realloc (current_list, NULL,
999
999
                                                  ((current_list_sz + 1)
1000
1000
                                                   * sizeof (JobInfo *))));
1001
1001
                current_list = new_list;
1055
1055
                if (! (event_caused || num_jobs))
1056
1056
                        num_responses++;
1057
1057
 
1058
 
        NIH_MUST (current_job = nih_new ((current_instance
 
1058
        current_job = NIH_MUST (nih_new ((current_instance
1059
1059
                                          ? (void *)current_instance
1060
1060
                                          : (current_list
1061
1061
                                             ? (void *)current_list
1110
1110
        nih_assert (process_pid > 0);
1111
1111
        nih_assert (current_job != NULL);
1112
1112
 
1113
 
        NIH_MUST (new_list = nih_realloc (current_job->procs, current_job,
 
1113
        new_list = NIH_MUST (nih_realloc (current_job->procs, current_job,
1114
1114
                                          ((current_job->procs_sz + 1)
1115
1115
                                           * sizeof (ProcInfo))));
1116
1116
        current_job->procs = new_list;
1159
1159
        if (current_instance) {
1160
1160
                JobInfo **new_list;
1161
1161
 
1162
 
                NIH_MUST (new_list = nih_realloc (current_instance->jobs,
 
1162
                new_list = NIH_MUST (nih_realloc (current_instance->jobs,
1163
1163
                                                  current_instance,
1164
1164
                                                  ((current_instance->jobs_sz + 1)
1165
1165
                                                   * sizeof (JobInfo *))));
1169
1169
        } else if (current_list) {
1170
1170
                JobInfo **new_list;
1171
1171
 
1172
 
                NIH_MUST (new_list = nih_realloc (current_list, NULL,
 
1172
                new_list = NIH_MUST (nih_realloc (current_list, NULL,
1173
1173
                                                  ((current_list_sz + 1)
1174
1174
                                                   * sizeof (JobInfo *))));
1175
1175
                current_list = new_list;
1364
1364
        for (ptr = args; ptr && *ptr; ptr++) {
1365
1365
                char *new_msg;
1366
1366
 
1367
 
                NIH_MUST (new_msg = nih_realloc (msg, NULL, (strlen (msg)
 
1367
                new_msg = NIH_MUST (nih_realloc (msg, NULL, (strlen (msg)
1368
1368
                                                             + strlen (*ptr)
1369
1369
                                                             + 2)));
1370
1370
                msg = new_msg;
1533
1533
 
1534
1534
                env = getenv (arg);
1535
1535
                if (env) {
1536
 
                        NIH_MUST (new_arg = nih_sprintf (NULL, "%s=%s",
 
1536
                        new_arg = NIH_MUST (nih_sprintf (NULL, "%s=%s",
1537
1537
                                                         arg, env));
1538
1538
                        NIH_MUST (nih_str_array_addp (value, NULL, NULL,
1539
1539
                                                      new_arg));