diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-19 18:26:40 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-19 18:26:40 +0000 |
commit | 624188aec0e730375bb782a45ab3224b33dd30e9 (patch) | |
tree | 64a7f24d94f6ef3cb883b54ac3196bda160278a4 /miscutils/microcom.c | |
parent | 671ca33aa1804c1c4e26bf83635206dce7ed2623 (diff) | |
download | busybox-w32-624188aec0e730375bb782a45ab3224b33dd30e9.tar.gz busybox-w32-624188aec0e730375bb782a45ab3224b33dd30e9.tar.bz2 busybox-w32-624188aec0e730375bb782a45ab3224b33dd30e9.zip |
microcom: tiny shrink, adding comments
Diffstat (limited to 'miscutils/microcom.c')
-rw-r--r-- | miscutils/microcom.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/miscutils/microcom.c b/miscutils/microcom.c index ea48291ae..3c573eaa9 100644 --- a/miscutils/microcom.c +++ b/miscutils/microcom.c | |||
@@ -51,18 +51,17 @@ int microcom_main(int argc, char **argv) | |||
51 | enum { | 51 | enum { |
52 | OPT_X = 1 << 0, // do not respect Ctrl-X, Ctrl-@ | 52 | OPT_X = 1 << 0, // do not respect Ctrl-X, Ctrl-@ |
53 | OPT_s = 1 << 1, // baudrate | 53 | OPT_s = 1 << 1, // baudrate |
54 | OPT_d = 1 << 2, // wait for device response, msecs | 54 | OPT_d = 1 << 2, // wait for device response, ms |
55 | OPT_t = 1 << 3, // timeout, ms | 55 | OPT_t = 1 << 3, // timeout, ms |
56 | }; | 56 | }; |
57 | speed_t speed = 9600; | 57 | speed_t speed = 9600; |
58 | int delay = -1; | 58 | int delay = -1; |
59 | int timeout = -1; | 59 | int timeout = -1; |
60 | unsigned opts; | ||
60 | 61 | ||
61 | // fetch options | 62 | // fetch options |
62 | unsigned opts; | 63 | opt_complementary = "=1:s+:d+:t+"; // exactly one arg, numeric options |
63 | opt_complementary = "=1:s+:d+:t+"; // exactly one arg should be there | ||
64 | opts = getopt32(argv, "Xs:d:t:", &speed, &delay, &timeout); | 64 | opts = getopt32(argv, "Xs:d:t:", &speed, &delay, &timeout); |
65 | |||
66 | // argc -= optind; | 65 | // argc -= optind; |
67 | argv += optind; | 66 | argv += optind; |
68 | 67 | ||
@@ -71,14 +70,16 @@ int microcom_main(int argc, char **argv) | |||
71 | device_lock_file = xasprintf("/var/lock/LCK..%s", device_lock_file); | 70 | device_lock_file = xasprintf("/var/lock/LCK..%s", device_lock_file); |
72 | sfd = open(device_lock_file, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0644); | 71 | sfd = open(device_lock_file, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0644); |
73 | if (sfd < 0) { | 72 | if (sfd < 0) { |
73 | // device already locked -> bail out | ||
74 | if (errno == EEXIST) | 74 | if (errno == EEXIST) |
75 | bb_perror_msg_and_die("can't create %s", device_lock_file); | 75 | bb_perror_msg_and_die("can't create %s", device_lock_file); |
76 | // can't create lock -> don't care | ||
76 | if (ENABLE_FEATURE_CLEAN_UP) | 77 | if (ENABLE_FEATURE_CLEAN_UP) |
77 | free(device_lock_file); | 78 | free(device_lock_file); |
78 | device_lock_file = NULL; | 79 | device_lock_file = NULL; |
79 | } | 80 | } else { |
80 | if (sfd > 0) { | 81 | // %4d to make concurrent mgetty (if any) happy. |
81 | // %4d to make mgetty happy. It treats 4-bytes lock files as binary, | 82 | // Mgetty treats 4-bytes lock files as binary, |
82 | // not text, PID. Making 5+ char file. Brrr... | 83 | // not text, PID. Making 5+ char file. Brrr... |
83 | char *s = xasprintf("%4d\n", getpid()); | 84 | char *s = xasprintf("%4d\n", getpid()); |
84 | write(sfd, s, strlen(s)); | 85 | write(sfd, s, strlen(s)); |