Great approach, correctly defines the parameters of the pattern. Here is C variant, but attempting the same idea in one single pass.

int maxProduct(int* nums, int numsSize)
{
int i, j, max, tmax1, tmax2, toff;
/* One big loop */
max = nums[0];
for (i = 0; i < numsSize; i = j + 1)
{
/* Process the array by splitting it into segments divided by
zero entries. If there are negative numbers, then each segment
can have up to two sub-array sequences - one which includes the
first negative number and the other one which does not. */
for (toff = -1, j = i; j < numsSize && nums[j] != 0; ++j)
{
/* Update the product of the first sequence */
tmax1 = (j == i) ? nums[j] : nums[j] * tmax1;
max = tmax1 > max ? tmax1 : max;
/* If the second sequence is active , then keep updating
the product */
if (toff >= 0) {
tmax2 = (toff == j) ? nums[j] : nums[j] *tmax2;
max = tmax2 > max ? tmax2 : max;
}
/* If this is the first negative value, then mark the beginning
of the second sub-array sequence. */
else if (nums[j] < 0)
toff = j + 1;
}
/* Handle the case where zero is the maximum product. */
max = (j < numsSize) && max < 0 ? 0 : max;
}
/* Return maximum */
return max;
}